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. Closing main window from sub windows
Forum Updated to NodeBB v4.3 + New Features

Closing main window from sub windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 1.3k 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.
  • S Offline
    S Offline
    supratik123
    wrote on last edited by
    #1

    I have a main window under which I have placed three different widgets in the form of tabs. I want to close the entire main window when any error happens inside any of the sub windows or widgets placed in the form of tabs. I am unable to figure it out how to do so. Any help will be appreciated

    jsulmJ 1 Reply Last reply
    0
    • S supratik123

      I have a main window under which I have placed three different widgets in the form of tabs. I want to close the entire main window when any error happens inside any of the sub windows or widgets placed in the form of tabs. I am unable to figure it out how to do so. Any help will be appreciated

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @supratik123 So, you don't want to close the whole application?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @supratik123 So, you don't want to close the whole application?

        S Offline
        S Offline
        supratik123
        wrote on last edited by
        #3

        @jsulm Sorry if i made it unclear. I want to close the whole application actually

        jsulmJ 1 Reply Last reply
        0
        • S supratik123

          @jsulm Sorry if i made it unclear. I want to close the whole application actually

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @supratik123 Use https://doc.qt.io/qt-5/qcoreapplication.html#exit then

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • jsulmJ jsulm

            @supratik123 Use https://doc.qt.io/qt-5/qcoreapplication.html#exit then

            S Offline
            S Offline
            supratik123
            wrote on last edited by
            #5

            @jsulm Sorry it didn't worked out

            jsulmJ 1 Reply Last reply
            0
            • S supratik123

              @jsulm Sorry it didn't worked out

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @supratik123 Please tell us what you did and what happened.
              Saying it "didn't worked out" does not provide enough information to help you...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              0
              • A Offline
                A Offline
                anil_arise
                wrote on last edited by anil_arise
                #7

                @supratik123 what kind of errors to sub windows?

                S 1 Reply Last reply
                0
                • A anil_arise

                  @supratik123 what kind of errors to sub windows?

                  S Offline
                  S Offline
                  supratik123
                  wrote on last edited by
                  #8

                  @anil_arise My sub windows are getting connected to server using TCP. So if some error occurs in TCP, I want to close the whole application and not proceed further

                  1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @supratik123 Please tell us what you did and what happened.
                    Saying it "didn't worked out" does not provide enough information to help you...

                    S Offline
                    S Offline
                    supratik123
                    wrote on last edited by
                    #9

                    @jsulm Sorry for that. The scenario is I have a main window which is having three tabs which are widgtes. The three widgets are getting connected to three different servers using TCP. Now if error happens in any of the sub windows, I want my application to close entirely and not proceed further

                    jsulmJ 1 Reply Last reply
                    0
                    • S supratik123

                      @jsulm Sorry for that. The scenario is I have a main window which is having three tabs which are widgtes. The three widgets are getting connected to three different servers using TCP. Now if error happens in any of the sub windows, I want my application to close entirely and not proceed further

                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @supratik123 Can you please just tell me what did not work with https://doc.qt.io/qt-5/qcoreapplication.html#exit ?
                      I already understood what you want to do, no need to explain it again...

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      S 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @supratik123 Can you please just tell me what did not work with https://doc.qt.io/qt-5/qcoreapplication.html#exit ?
                        I already understood what you want to do, no need to explain it again...

                        S Offline
                        S Offline
                        supratik123
                        wrote on last edited by
                        #11

                        @jsulm The application is not closing actually. The process is continuing on encountering error

                        jsulmJ 1 Reply Last reply
                        0
                        • S supratik123

                          @jsulm The application is not closing actually. The process is continuing on encountering error

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @supratik123 Please show the code where you use https://doc.qt.io/qt-5/qcoreapplication.html#exit
                          How is anybody supposed to help you if you do not provide enough information?!

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          S 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @supratik123 Please show the code where you use https://doc.qt.io/qt-5/qcoreapplication.html#exit
                            How is anybody supposed to help you if you do not provide enough information?!

                            S Offline
                            S Offline
                            supratik123
                            wrote on last edited by Christian Ehrlicher
                            #13

                            @jsulm

                            try
                                          {
                                              //invoking the MCIS library using scope pointer member of MCIS static library
                                              this->m_libMCIS.reset(new MCIS(m_mcisTestConfig));
                            
                                              QString l_currentDateTime = QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss");
                                              l_currentDateTime.append("  TCP Communication Successful ");
                                              ui->m_receiverTxtEdit->append(l_currentDateTime);
                                              qDebug()<<"TCP Communication Successful";
                                          }
                                          catch (Error& e_error)
                                          {
                            
                                              QString l_currentDateTime = QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss");
                                              l_currentDateTime.append("  Error during TCP communication creation");
                                              ui->m_receiverTxtEdit->append(l_currentDateTime);
                                              qDebug()<<"Error during TCP communication creation";
                                              QMessageBox::critical(this, tr("communication error"),
                                                                    QString::fromStdString(e_error.getMessage()));
                                              ***QCoreApplication::exit();***
                            
                                          }
                                          catch(...)
                                          {
                                              QMessageBox::critical(this, tr("unknown error"),tr("MCIS Library communication error "));
                                          }
                            
                            jsulmJ 1 Reply Last reply
                            0
                            • S supratik123

                              @jsulm

                              try
                                            {
                                                //invoking the MCIS library using scope pointer member of MCIS static library
                                                this->m_libMCIS.reset(new MCIS(m_mcisTestConfig));
                              
                                                QString l_currentDateTime = QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss");
                                                l_currentDateTime.append("  TCP Communication Successful ");
                                                ui->m_receiverTxtEdit->append(l_currentDateTime);
                                                qDebug()<<"TCP Communication Successful";
                                            }
                                            catch (Error& e_error)
                                            {
                              
                                                QString l_currentDateTime = QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss");
                                                l_currentDateTime.append("  Error during TCP communication creation");
                                                ui->m_receiverTxtEdit->append(l_currentDateTime);
                                                qDebug()<<"Error during TCP communication creation";
                                                QMessageBox::critical(this, tr("communication error"),
                                                                      QString::fromStdString(e_error.getMessage()));
                                                ***QCoreApplication::exit();***
                              
                                            }
                                            catch(...)
                                            {
                                                QMessageBox::critical(this, tr("unknown error"),tr("MCIS Library communication error "));
                                            }
                              
                              jsulmJ Online
                              jsulmJ Online
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by jsulm
                              #14

                              @supratik123 Was the catch (Error& e_error) called? Did you close the QMessageBox::critical dialog? And do you have an event loop running?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              S 1 Reply Last reply
                              1
                              • Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @supratik123 said in Closing main window from sub windows:

                                QCoreApplication::exit()

                                This will quit the eventloop, if none is running, nothing will happen - so does the eventloop run?
                                Do you have maybe set QApplication::setQuitOnLastWindowClosed(false) somewhere?

                                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                Visit the Qt Academy at https://academy.qt.io/catalog

                                S 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @supratik123 Was the catch (Error& e_error) called? Did you close the QMessageBox::critical dialog? And do you have an event loop running?

                                  S Offline
                                  S Offline
                                  supratik123
                                  wrote on last edited by
                                  #16

                                  @jsulm Yes the error is called and I am closing the QMessageBox whenever it is popping up. I dont;t have any event loop running

                                  1 Reply Last reply
                                  0
                                  • Christian EhrlicherC Christian Ehrlicher

                                    @supratik123 said in Closing main window from sub windows:

                                    QCoreApplication::exit()

                                    This will quit the eventloop, if none is running, nothing will happen - so does the eventloop run?
                                    Do you have maybe set QApplication::setQuitOnLastWindowClosed(false) somewhere?

                                    S Offline
                                    S Offline
                                    supratik123
                                    wrote on last edited by
                                    #17

                                    @Christian-Ehrlicher No I haven't set it anywhere

                                    jsulmJ 1 Reply Last reply
                                    0
                                    • S supratik123

                                      @Christian-Ehrlicher No I haven't set it anywhere

                                      jsulmJ Online
                                      jsulmJ Online
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      @supratik123 then just call exit() (I mean the C lib function).

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      1

                                      • Login

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