Important: Please read the Qt Code of Conduct -

Qt.conf since 5.3.1 ignored ?

  • What happens, why since Qt 5.3.1 qt.conf ignored on application startup?
    I have a copy of plugins directory in application folder and qt.conf with content:

    On Qt 5.2.1 application load plugins from local directory (as described in qt.conf)
    Since Qt 5.3.1 / 5.3.2, ignore qt.conf and application load plugins from qt build directory.

    It's make a problem with application deployment.

  • Moderators

    This question is more suited for Interest mailing list, where much more Qt developers can read and respond. I suggest sending a message there.

  • Ok, thanks.
    Could you get me detailed information about this mailing list?

  • Moderators

  • Hmm (sorry sierdzio for answering here ;-) but it sounds like you've been bitten by "this bug":

    Perhaps you are calling QCoreApplication::applicationDirPath() before QApplication app (argc, argv)?

  • Moderators

    No need to apologise, this is an important hint.

    -I think it is vitally important to remember, that Qt does not support instantiating any QObjects before QCoreApplication is constructed. If you do that, you are on your own (which sort of makes that bug invalid). Looking through Qt docs right now, I notice that this fact is not mentioned by the documentation. I am not an expert on this, but I think that is a bug instead.-

    Edit: apologies, the paragraph above is only true for QApplication and UI objects (QWidgets).

    Edit 2: actually, it's not as easy. See my next post.

  • Well that bug was reported because of "this discussion":

    -You mean if I call the static method QCoreApplication::libraryPaths() it creates a QObject for me?-
    sorry talking too much in telephone, didn't see your edit :-)

  • Moderators

    I have found the conversation I have based my last post on: "link":

    Thiago, who advances the claim that you should always construct a Q*Application first, is the maintainer of QtCore module and has deep knowledge of how it all works internally.

  • Interesting, I like Thiago's answer: "Qt is not supported before the creation of QCoreApplication. Your use-case is not supported, so no answer is necessary."
    He's right, if you look at the startup source code, you'll see that Qt is a bit confused/braindead before the constructor is done.

  • qlibraryinfo.cpp line 154:
    QSettings *QLibraryInfoPrivate::findConfiguration()

    Does Qt find the path to the qt.conf?

  • I'm sorry I forgot write about result.
    Was and not working:
    QSettings settings_app(APP_VENDOR_NAME_C, APP_NAME_C SETTING_APP);

    if(!settings_app.value(KEY_NATIVE_UI, false).toBool()) {
        QApplication::setStyle(new CMStyle());
    QApplication a(argc, argv);


    Become and working:
    QApplication a(argc, argv);

    QSettings settings_app(APP_VENDOR_NAME_C, APP_NAME_C SETTING_APP);
    if(!settings_app.value(KEY_NATIVE_UI, false).toBool()) {
        QApplication::setStyle(new CMStyle());


    The reason in following: befor version 5.3.1 this call QApplication::setStyle(new CMStyle()); did not lead to the initialization of the search paths plugins.
    I. e. it happened when QApplication is constructed.

    see QFactoryLoader::update() line 114 call:
    QStringList paths = QCoreApplication::libraryPaths();

    But from 5.3.1 when you call the installation style QApplication :: setStyle () initializes the variable which keep the path to the plug-ins
    (But plugins is not being loaded YET !!!, just intialize) but when QApplication is constructed, Qt "sees" that the path to the plug-ins already have and ignores the path from the config and load libraris with plugins.

    see: qtbase/src/corelib/plugin/qlibrary_win.cpp function
    bool QLibraryPrivate::load_sys() line 117
    pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
    This is the place where plugins dll is loading.

Log in to reply