GUI closes
Unsolved
General and Desktop
-
I'm new to qt my qt GUI closes after running my application
My code:
#include "GUI.h" #include <QtWidgets/QApplication> void createGUI(int argc, char* argv[]); QApplication* app; GUI* gui; int main(int argc, char *argv[]) { createGUI(argc, argv); return app->exec(); } void createGUI(int argc, char *argv[]) { QApplication a(argc, argv); GUI w; app = &a; gui = &w; w.setWindowFlags(Qt::MSWindowsFixedSizeDialogHint); w.show(); }
-
You are creating the a & w as local objects. They will be destroyed once the function call is over. Your app is crashing at app-exec() as app object is destroyed once the function call createGUI is complete.
-
Hi and welcome to devnet,
In addition to to what @dheerendra wrote, since you are new to Qt, please follow the code examples in the documentation. In none of them you'll see such a way to setup and run a Qt application.