Search code examples
c++windowsenvironment-variablesqt5qfiledialog

Why does the nativeness of my Qt file dialog depend on environment variables?


According to older answers like https://stackoverflow.com/a/2609618/2492801, Qt file dialogs are only native when static functions have been used for dialog creation. This is not true here (and actually the comment at the answer cited above states that this is not true anymore).

I have subclassed QFileDialog and call the exec() method to display the dialog. In eclipse I set the PATH environment variable in my launch configuration for finding the DLLs. What surprises me is that I get the native Windows file dialog if I select "Append environment to native environment" and I get the non-native Qt file dialog if I select "Replace native environment with specified environment" in the eclipse launch configuration.

Does anybody have an explanation for this? Which environment variable determines whether my file dialog is native or not?

I am using Qt 5.14.1 and Mingw-w64.


Solution

  • The reason is simple: there are other Qt libraries in my path. For example TortoiseHg and MikTeX come with Qt libraries and I have installed both of them. Apparently some of their DLLs get loaded, when they are within the path and this influences Qt's behaviour. If I replace the native environment, only the libraries from the path defined by my launch configuration are loaded.