Alert/Error window summon after main Widget is closed?
-
Hi, i'm wondering on how to create an error/messagebox window which pops after the program is closed (main window)? is it even possible to call a window after the "main program" dies? thanks in advance, and you guys are awesome :)
-
Sure, why not.
A simplest example:int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); a.exec(); QMessageBox::information(nullptr, "hi", "hello"); }
-
This post is deleted!
-
@Chris-Kawa, thanks for replying, it is working and i edited it to fit my case better, yet i meet another problem, the main widget does exit and is innactive, but the window itself is still living. (GUI is visible but not interactive anymore), the messagebox pops and only after i confirm it, both main widget window and messagebox die completely. how do i make the widget disappear before the message pop? here's my code of main.cpp:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();int returnvalue = a.exec(); if(returnvalue == 1000) QMessageBox::information(nullptr, "Error", "some error"); return returnvalue;
}
//Lubuntu x32 Qt5.4 btw.
-
Simple enough:
int main(int argc, char *argv[]) { QApplication a(argc, argv); int returnvalue = 0; { Widget w; w.show(); returnvalue = a.exec(); } //widget goes out of scope and is destroyed if(returnvalue == 1000) QMessageBox::information(nullptr, "Error", "some error"); return returnvalue; }
-
@Chris-Kawa, i see what you did there! :d
thanks, didn't even think about that approach before! very useful!