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?

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.
  • Arty.McLabinA Offline
    Arty.McLabinA Offline
    Arty.McLabin
    wrote on 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
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 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 Arty.McLabinA 2 Replies Last reply
      1
      • Chris KawaC Chris Kawa

        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 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Chris KawaC Chris Kawa

          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");
          }
          
          
          Arty.McLabinA Offline
          Arty.McLabinA Offline
          Arty.McLabin
          wrote on 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
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 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;
            }
            
            Arty.McLabinA 1 Reply Last reply
            1
            • Chris KawaC Chris Kawa

              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;
              }
              
              Arty.McLabinA Offline
              Arty.McLabinA Offline
              Arty.McLabin
              wrote on 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

              • Login

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