How to deal with "QPixmap: Must construct a QGuiApplication before a QPixmap"
-
@laozeng1982 said in How to deal with "QPixmap: Must construct a QGuiApplication before a QPixmap":
QLibrary mylib("CarnacPlotQt5.dll");
if(mylib.load())Why are you doing this?!
Your application already links against this DLL, there is no need to dynamically load it... -
@laozeng1982 assuming you don't have any static QPixmaps or so,
move
QApplication app(argc, argv);
to the top of your main function -
@J-Hilk Hi, I move the "QApplication app(argc, argv);" to the top and remove QLibrary statement.
but It still the same error.
-
@laozeng1982 than you have probably somewhere a static QObject
-
@J-Hilk So, how Can I found where is the static Object?
If I don't start the module using the 3rd dlls, it will not raise the error, according to the debugger information, it was in the 3rd part dlls, even I found it, I can't modify it.
-
@laozeng1982 its a dll, it's dynamically loaded -> load it after your QApplication instance is up and running.
-
@J-Hilk said in How to deal with "QPixmap: Must construct a QGuiApplication before a QPixmap":
@laozeng1982 than you have probably somewhere a static QObject
That would have been my initial comment too. But when I looked at the first post in this thread I see
- A stack trace showing me code called from some action/checkbox; and
- Console output showing code running as far as the
app.exec()
.
Assuming the OP means the error message about "no application" comes at this point how can it stem from a static
QObject
? That would happen literally at start up.