Qt application is a 'QApplication' / not respecting qt.conf
-
We are deploying two different Qt applications via rpm. One is a QGuiApplication and the other is a QApplication.
We are using Qt version 5.4.1 on RHEL7( v.7.1 ).
We are deploying a qt.conf alongside the Qt Application binary. It has a [Paths] groups followed by a Prefix = /path/to/Qt/Installation.
When we turn on QT_DEBUG_PLUGINS, the application that is a QGuiApplication is respecting the settings in qt.conf while the application that is a QApplication is not. When I looked through the Qt code, I thought that a QApplication is derived from a QGuiApplication which, in turn, is a subclass of QCoreApplication. Shouldn't an application of class QApplication respect the settings in qt.conf?
-
Hi and welcome to devnet,
Indeed QApplication should also respect qt.conf
Can you show the content of both your qt.conf files ?
Can you reproduce that with a minimal application ?
-
Maybe I figured it out. For the application that does work with qt.conf, the QT entry in its .pro file is
QT += core gui network xml widgets sql opengl quick qml
For the application that doesn't work with the qt.conf file, it's .pro file as the following QT entry:
QT += qml quick sql widgets
The qt.conf looks like:
[Paths] Prefix = /opt/qt/Qt-5.4.1
-
Well I have been at trying to create a scaled down app. Here is what I think I know:
- The main application is declared as a QApplication
- The main.cpp is instantiating three objects -- all of type QObject.
- One of these objects is our DatabaseMgr object and it is trying to connect to an SQLite database.
- With the QT_DEBUG_PLUGINS environment variable set to 1, we see
QSqlDatabase: available drivers: QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins QSqlDatabase: QSQLITE driver not loaded QSqlDatabase: available drivers: QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins QSqlDatabase: QSQLITE driver not loaded QSqlDatabase: available drivers: QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins This application failed to start because it could not find or load the Qt platform plugin "xcb".``` Is the problem that those three objects are all instantiated as *QObject* and that is why *qt.conf* is not respected?
-
Hi, in your main.cpp, if you're instantiating your objects before doing
QApplication a(argc, argv);
then maybe you're bitten by this bug:
https://bugreports.qt.io/browse/QTBUG-38598One workaround is to use addLibraryPath() instead of a qt.conf (or reorder the instantiating of the objects). Good news (for Xmas) is that this bug is fixed in Qt 5.6.
-
All,
A colleague pointed out:
I don't think Qt 5.6 would have helped in this case. The root cause was that the source code was referencing a plugin before the qt.conf file was loaded. The loading of the qt.conf file is what has been set up to tell the application where to find the Qt libraries. Since the qt.conf file was not loaded yet, it was unable to determine where the plugin was and erred out. This would still be the case even with a newer version of Qt.
Is that true? Does Qt 5.6 address this issue?