Qt reports QWidget: Must construct a QApplication before a QWidget error
The reason why Qt reported this error is that the program uses LIBS to add the static library lib library file and the running mode (Debug/Release) mode to load the corresponding dll dynamic library mismatch problem
Solution: Pro-test is effective
- When loading a static library in a pro file, the distinction is release and debug mode
# Load static library: load the corresponding library according to the situation # d represents the debug library compiled in debug mode win32:CONFIG(release, debug|release): { LIBS += $$PWD/lib_x64/release/libTest*.a } else:win32:CONFIG(debug, debug|release): { LIBS += $$PWD/lib_x64/debug/libTestd*.a }
- Copy the dynamic library files in release and debug mode at the same time in the same level directory of the compiled executable exe file: dll file
libTest.dll #release dynamic library, which is consistent with the static library lib*.a files except for the suffixes libTestd.dll # debug dynamic library, which is consistent with the static library lib*.a file except the suffix is ??inconsistent
When using Qt to compile and run the program, Qt will automatically select the corresponding library to compile and run