Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Alert/Error window summon after main Widget is closed?
QtWS25 Last Chance

Alert/Error window summon after main Widget is closed?

Scheduled Pinned Locked Moved General and Desktop
alertclosederrormessagemessageboxwindowafterexitquit
6 Posts 3 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arty.McLabin
    wrote on 12 Apr 2015, 17:54 last edited by
    #1

    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 :)

    Static linking is cool. Really.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 12 Apr 2015, 21:57 last edited by
      #2

      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");
      }
      
      
      R A 2 Replies Last reply 12 Apr 2015, 23:41
      1
      • C Chris Kawa
        12 Apr 2015, 21:57

        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");
        }
        
        
        R Offline
        R Offline
        Ruslan F.
        wrote on 12 Apr 2015, 23:41 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • C Chris Kawa
          12 Apr 2015, 21:57

          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");
          }
          
          
          A Offline
          A Offline
          Arty.McLabin
          wrote on 13 Apr 2015, 15:49 last edited by Arty.McLabin
          #4

          @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.

          Static linking is cool. Really.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 13 Apr 2015, 16:55 last edited by
            #5

            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;
            }
            
            A 1 Reply Last reply 13 Apr 2015, 19:15
            1
            • C Chris Kawa
              13 Apr 2015, 16:55

              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;
              }
              
              A Offline
              A Offline
              Arty.McLabin
              wrote on 13 Apr 2015, 19:15 last edited by
              #6

              @Chris-Kawa, i see what you did there! :d
              thanks, didn't even think about that approach before! very useful!

              Static linking is cool. Really.

              1 Reply Last reply
              0

              6/6

              13 Apr 2015, 19:15

              • Login

              • Login or register to search.
              6 out of 6
              • First post
                6/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved