Important: Please read the Qt Code of Conduct -

qt.conf platform plugin path

  • Hi,

    I'm deploying a Qt desktop application on Windows and on Linux platforms, linking it to Qt shared libraries (ver. 5.9).

    I used qt.conf file to specify custom platform plugin path, and everything works fine.

    Nevertheless, I've the need to specify different paths for platform plugins on Windows and on Linux.

    Is it possible to edit the qt.conf file with "unix" and "win32" scopes (or similar), avoiding separate platform-dependent qt.conf files?

    I cannot find documentation about that (I see a [Platforms] group here, but it appears not suitable to my purpose).

    Thanks in advance for your help.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    AFAIK, no.

    Out of curiosity, where do you put these plugins ?

  • Hi,

    thank you for your reply and sorry for the delay of my answer.

    On Windows I actually use the platform plugin at the default path ("platforms" subdirectory in the executable file directory), while on Linux I don't want this default behavior, since the executable file resides in /usr/bin directory (I don't want to get the /usr/bin path "dirty" with application dependent stuff), so I managed to have the platform plugin under /usr/local/lib/<myApp>/platforms.

    In order to get the "platform dependent behavior" of qt.conf file, I added a snippet in .pro file, using platform scopes, that creates the proper qt.conf file.


  • @cian_1706 Although I never used qt.conf before, from the link in your post (Using qt.conf) it looks like the per-platform settings is already supported, so I imagine something as follows in just one qt.conf:

    WindowsArguments = Plugins=C:/path/to/plugins/under/Windows
    LinuxArguments = Plugins=/path/to/plugins/under/Linux

    If you already tested that and it doesn't work, I think that creating different qt.conf per platform from the .pro itself is a good way to go (you need to edit just one place in case of changes)

  • Hi, one other alternative is to skip using qt.conf files.

    Instead you can specify the path to the plugins using c++ code. For it to work you need to do it before the constructor of QApplication starts (that's when the plugins are loaded), so best place is in your main.cpp, say like this:

    int main(int argc, char *argv[])
    #ifdef Q_OS_LINUX
        QApplication a(argc, argv);
        MainWindow w;

Log in to reply