PDA

View Full Version : Qt Application looks different after being installed in Windows



pixaeiro
30th December 2018, 16:41
Hello,

I'm developing an application for Windows that uses Qt 5.10 and is compiled with Visual Studio 2015, and I'm using NSIS to pack and build the installer.

When I run the application that I have installed to the "c:\Program Files" directory it looks different than the application that I run from the build directory.

This is how it looks when I run it from the build directory:

13004

And this is how it looks when I run it from the "c:\Program Files" directory after it has been installed:

13005

As you can see, the installed instance has something like a Windows XP look, with 3D buttons and frames.

Does anybody know what could be happening? Or has a hint of what to look for?

Thank you in advance for your help!

d_stranz
30th December 2018, 17:29
It looks like the default style used in your build environment is different from that used in your installed runtime environment. Does it look different in your build environment when you run Debug vs. Release mode builds?

You can also look at your Output window in Visual Studio when you run in debug mode. It will show a list of all of the DLLs loaded. In my system, it shows this for the style plugin:


'MyApp.exe' (Win32): Loaded 'C:\Qt\5_11_1\5.11.1\msvc2015_64\plugins\styles\qw indowsvistastyled.dll'

I am not sure how you can determine which style plugin is being loaded when you are running your installed app. Maybe you can retrieve the QStyle instance for qApp, then query the static QMetaObject for its className()?

pixaeiro
31st December 2018, 14:49
Hello d_stranz,

Thank you very much for your reply!

Following your instructions I tested the configuration of my application and I found that if I delete the qt.conf file in the installed directory my application looks the same as in the build directory (Windows 10).

My application has a qt.conf file that tells Qt where to find the plugins:


[Paths]
Plugins=qt_plugins

And I have two files in this directory:
C:\Program Files\PixaFlux\qt_plugins\imageformats\qico.dll
C:\Program Files\PixaFlux\qt_plugins\platforms\qwindows.dll

I copy these two files from the Qt library path:
E:\Libraries\Qt\5.10.1\5.10.1\msvc2015_64\plugins

When I update to a new Qt library build I go to Qt downloads and grab one of the prebuilt libraries:
This is the latest I downloaded
https://download.qt.io/official_releases/qt/5.10/5.10.1/ file qt-opensource-windows-x86-5.10.1.exe

Unfortunately my Visual Studio doesn't display the Qt libraries it loads. Is there a flag I need to enable for this?

Do you think I need to modify the qt.conf file to make my application look with flat Windows 10 widgets?

Thank you again!

Added after 7 minutes:

Oh! My application was not including the style plugin!!!

I copied the plugin you said to the qt_plugins directory and now everything looks fancy again:

C:\Program Files\PixaFlux\qt_plugins\styles\qwindowsvistastyl e.dll

Thank you very much!!!

Lesiok
31st December 2018, 15:22
On Windows You have a tool : windeployqt.exe.

d_stranz
31st December 2018, 16:05
Unfortunately my Visual Studio doesn't display the Qt libraries it loads. Is there a flag I need to enable for this?

Sure it does. When you run your program in debug mode, open the window named "Output". If you don't see it, use View -> Output from the menu to open it. As your program runs, all of the DLLs it loads and unloads will be displayed there.


On Windows You have a tool : windeployqt.exe.

This is for building installers, right? The OP is using NSIS, which works just fine for Qt applications.

For statically analyzing the runtime dependencies in a Windows program, there is the old "depends" program. This may not work to identify dynamically loaded plugins like styles, but does find the dependencies for link libraries.


I copied the plugin you said to the qt_plugins directory and now everything looks fancy again

Just remember to add it to your NSIS script.

ChristianEhrlicher
1st January 2019, 10:05
This is for building installers, right?.
No, it scans the executable and copies all needed Qt dlls and plugins to a dedicated directory so they can be used with an installer: http://doc.qt.io/qt-5/windows-deployment.html