Alert/Error window summon after main Widget is closed?
-
wrote on 12 Apr 2015, 17:54 last edited by
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"); }
-
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"); }
wrote on 12 Apr 2015, 23:41 last edited byThis post is deleted! -
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"); }
wrote on 13 Apr 2015, 15:49 last edited by Arty.McLabin@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; }
-
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; }
wrote on 13 Apr 2015, 19:15 last edited by@Chris-Kawa, i see what you did there! :d
thanks, didn't even think about that approach before! very useful!
6/6