Source: Building a static Qt for Windows using MinGW
Download Qt and install it. Also select toolchain MinGW:
Remember directory, where MinGW was installed. For example *D:\Qt\Tools\mingw530_32\bin*
Download script windows-build-qt-static.ps1. Save it to directory *D:\Qt*
Select Qt version from Qt Downloads and remember url for {VERSION}/{VERSION}/single/qt-everywhere-opensource-src-{VERSION}.zip. For example http://download.qt.io/official_releases/qt/5.9/5.9.1/single/qt-everywhere-opensource-src-5.9.1.zip
Create file windows-build-run.bat with content:
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& 'D:\Qt\windows-build-qt-static.ps1' -QtSrcUrl 'http://download.qt.io/official_releases/qt/5.9/5.9.1/single/qt-everywhere-opensource-src-5.9.1.zip' -QtStaticDir 'D:\Qt\Static591' -MingwDir 'D:\Qt\Tools\mingw530_32' -QtVersion '5.9.1-Static'
where * -QtSrcUrl - Url to source codes archive; * -QtStaticDir - Directory where the static version are installed. * -MingwDir - Path to MinGW toolchain.
Or you can meet error like
ERROR: Invalid command line parameter 'Static'.
mingw32-make: *** No targets specified and no makefile found. Stop.
mingw32-make: *** No rule to make target 'install'.
Run cmd.exe, change directory to D:\Qt, start file windows-build-run.bat
If you see error about SQLite, open file windows-build-qt-static.ps1 in editor and replace -qt-sql-sqlite with -sql-sqlite.
Wait some hours.............
Add compiled Qt to Qt Creator: Tools → Options → Build & Run → Qt Versions → Add.... Browse to qmake.exe.
Add new kit: Tools → Options → Build & Run → Kit → Add.... Select compiler C/C++ = MinGW 5.3.0, debugger = GNU gdb from MinGW 5.3.0 and just compiled Qt Version.
Select kit for project:
After build we could see a large executable file.