When I cross-compile Qt 5.8.0 from source myself and use it to build the Qt "Dynamic Layouts" example from Qt Widgets for Microsoft Windows, it looks old-fashioned, as if it were running on Windows 2000, as shown in the left window below. However, if I compile the exact same program using the pre-built mingw-w64-x86_64-qt5-static package (version 5.8.0-1) from MSYS2, it looks like a nice modern Windows application, as shown in the right window below. How can I fix my version of Qt so that GUIs built with it will look nice? Is there a configuration option I am missing?
One thing to look into is the QWindowsVistaStyle
class. I noticed that when I compiled my program in MSYS2, I had to add -luxtheme
because that class referred to some functions from there, like GetThemeColor
. Those functions are only available in Windows Vista and later. When I cross-compiled using my own Qt on Linux, I didn't need that library, so perhaps that class was somehow disabled in my build.
I built the cross-compiled Qt and the old-looking Dynamic Layouts example using commit f51d834 of my nixcrpkgs repository. If you look at the code in that commit, it will show you exactly what commands were run to build the mingw-w64 cross-compiler, and build Qt, and build the Qt examples, including Dynamic Layouts. You can build it yourself if you install Nix, download nixcrkpkgs, and then run nix-build -A pkgs.i686-w64-mingw32.qt.base-examples
in the nixcrpkgs directory. You can see my build recipe for the Qt package in that commit.
I ran this script in a MINGW64 shell in MSYS2 to build the example and got good results. It relies on the mingw-w64-x86_64-qt5-static package from MSYS2. You can see the build recipe for that package.
I had the same issue after upgrading from Qt5.9.1 to Qt5.12.
Placing qwindowsvistastyle.dll, which I found to be in Qt\5.12.0\msvc2017_64\plugins\styles, needed to be placed in my applicationDir\styles directory.