how stop the "QPixmap: Must construct a QGuiApplication before a QPixmap" in a dll
-
@JKSH Thanks for your reply.
I load the dll myself after the Application is created in the main function of the parent app.
The dll loads it's own icon buttons as soon as it loaded. This happens in a "start" function in the dll after it loads successfully.
No global static objects used. -
You're welcome.
@kenchan said in how stop the "QPixmap: Must construct a QGuiApplication before a QPixmap" in a dll:
I load the dll myself after the Application is created in the main function of the parent app.
The dll loads it's own icon buttons as soon as it loaded. This happens in a "start" function in the dll after it loads successfully.
No global static objects used.Hmm... that's very interesting.
Add some debugging calls in your code. What do you see? (Also pay attention to the order of messages: When does the QPixmap error appear, relative to these debug messages?):
// main.cpp int main(int argc, char *argv[]) { qDebug() << "Main application, before qApp:" << QCoreApplication::instance(); QApplication app(argc, argv); qDebug() << "Main application, after qApp:" << QCoreApplication::instance(); // ... } // DLL void start() { qDebug() << "DLL, before loading icons:" << QCoreApplication::instance(); // ... Load icons here... qDebug() << "DLL, after loading icons:" << QCoreApplication::instance(); }
-
@JKSH said in how stop the "QPixmap: Must construct a QGuiApplication before a QPixmap" in a dll:
I load the dll myself after the Application is created in the main function of the parent app.
How do you do this?
-
@Christian-Ehrlicher
I use a QLibrary to load my dlls. -
@kenchan said in how stop the "QPixmap: Must construct a QGuiApplication before a QPixmap" in a dll:
I use a QLibrary to load my dlls.
I would deny this. Please use a dependency walker to see if it does not get loaded directly. Also use QT_FATAL_WARNINGS and/or a debugger to get the backtrace for the warning.
-
@kenchan
This the output from the inserted qDebug code.Main application, before qApp: QObject(0x0)
...
Main application, after qApp: RCApplication(0x59f1baab10)
...
dll is loaded using QLibrary
...
DLL, before loading icons: RCApplication(0x59f1baab10)
...
DLL, after loading icons: RCApplication(0x59f1baab10)
-
And when comes the error message?
Also please use a debugger + QT_FATAL_WARNINGS as I suggest so you can see which code triggers the error message. -
It is true! These dlls are not known to the application at link time! so how can it know to load them until I want it to?
There are several of these dlls and the user can load and unload them using a dialog.
The application remembers which ones are to be loaded and loads them on each run, again using QLibrary. -
Again: use a debugger and QT_FATAL_WARNINGS as described e.g. here to see which QPixmap triggers your error!
-