QWidget Must construct a QApplication before a QWidget
This error message is indicating that you are trying to create a QWidget object before you have created a QApplication object. In order to create any GUI elements using Qt, you must first create a QApplication object to handle the event loop and other necessary components of the GUI framework.
To fix this error, you should create a QApplication object at the beginning of your program before creating any QWidget objects. Here is an example of how to create a QApplication object:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// create your QWidget objects and show them here
return app.exec();
}
By creating the QApplication object first, you ensure that all necessary components are initialized before any GUI elements are created
原文地址: https://www.cveoy.top/t/topic/fFiN 著作权归作者所有。请勿转载和采集!