Solved Qt6: QWidget: Must construct a QApplication before a QWidget
-
I have a Qt C++ main application and shared library that both compiles and works good with Qt 5.15.0
After I update toQt 6.0.0
I still get a clean compile of both projects.The app loads the library with no errors (all symbols are ok), but when I try to invoke the library GUI (QWidget) my app crashes and gives me this run-time error below:
QWidget: Must construct a QApplication before a QWidget
Here is the
shared library
GUI constructor method that is called:Dialog::Dialog(Plugin* plugin, QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) // <--- CRASHS HERE ---- { ui->setupUi(this); // other code.... }
My questions are:
1) Why it works on Qt 5.15 and crashes in Qt 6.0.0
2) How can I fix it?My setup is:
- Ubuntu 20.04 x64
- Qt 6.0.0
- Qt Creator IDE 4.14.0
UPDATE 1
- Yes, both main app and shared library are compiled in the debug mode
- First my main app launches completly and only store the function pointers of the shared library. After that, the main app GUI opens ok. Finally the user manually click to open the shared library GUI. In that moment, the app crashes.
UPDATE 2
The complete error message is:
can't find linker symbol for virtual table for `App' value found `std::ctype<char>::id' instead QWidget: Must construct a QApplication before a QWidget
-
Sorry...it was my mistake.
In my
CMakeLists.txt
I was always linking with Qt 5...
I changed it to Qt 6 and it works good! -
Sorry...it was my mistake.
In my
CMakeLists.txt
I was always linking with Qt 5...
I changed it to Qt 6 and it works good!