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. showing parent while closing child form
Forum Updated to NodeBB v4.3 + New Features

showing parent while closing child form

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 740 Views 3 Watching
  • 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.
  • R Offline
    R Offline
    rahulvishwakarma
    wrote on last edited by
    #1

    hi to all, I'm using qt 5.7 in centos7.5 linux. i want to show parent form while closing current child window. i am doing like this :-

    void DialogAddModifyMemberRecords::on_pushButtonOK_clicked()
    {
        this->hide();
    
        this->parentWidget()->show();
        //this->close();
    
    }
    

    but shows error

    ```Starting /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs...
    The program has unexpectedly finished.
    /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs crashed.
    

    how to get rid of this.

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • R rahulvishwakarma

      hi to all, I'm using qt 5.7 in centos7.5 linux. i want to show parent form while closing current child window. i am doing like this :-

      void DialogAddModifyMemberRecords::on_pushButtonOK_clicked()
      {
          this->hide();
      
          this->parentWidget()->show();
          //this->close();
      
      }
      

      but shows error

      ```Starting /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs...
      The program has unexpectedly finished.
      /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs crashed.
      

      how to get rid of this.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @rahulvishwakarma
      Step through your code in debugger to determine exact cause (stack trace on crash). This is standard debugging technique before you ask question like this. One possibility: if your program is on default "quit after last window not visible", and child is only visible window, and you close before showing parent, I don't know if that could be a problem. Try showing parent before hiding child, just in case.

      Also, if this child is a QDialog, how is parent calling/showing it (exec(), or is it modal/modeless??), and why is child hide()-ing itself, dialogs often go via accept/reject/done()?

      It's not always best design to have child show parent. Might be nicer to have parent notified of child closure so that it can re-show itself.

      1 Reply Last reply
      1
      • R Offline
        R Offline
        rahulvishwakarma
        wrote on last edited by
        #3

        i used all choices you suggested(accept, reject ,done) and also setAttribute(Qt::WA_DeleteOnClose); in child and parent form.
        but having same error :- The program has unexpectedly finished.

        jsulmJ 1 Reply Last reply
        0
        • R rahulvishwakarma

          i used all choices you suggested(accept, reject ,done) and also setAttribute(Qt::WA_DeleteOnClose); in child and parent form.
          but having same error :- The program has unexpectedly finished.

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

          @rahulvishwakarma said in showing parent while closing child form:

          The program has unexpectedly finished

          use debugger as already suggested

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

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rahulvishwakarma
            wrote on last edited by
            #5

            in debugger this showed following window at point of crash.

            Signal name : SIGSEGV
            Signal meaning : Segmentation fault

            jsulmJ 1 Reply Last reply
            0
            • R rahulvishwakarma

              in debugger this showed following window at point of crash.

              Signal name : SIGSEGV
              Signal meaning : Segmentation fault

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

              @rahulvishwakarma You have to look at the stack trace (or post it here).

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

              1 Reply Last reply
              1
              • R rahulvishwakarma

                hi to all, I'm using qt 5.7 in centos7.5 linux. i want to show parent form while closing current child window. i am doing like this :-

                void DialogAddModifyMemberRecords::on_pushButtonOK_clicked()
                {
                    this->hide();
                
                    this->parentWidget()->show();
                    //this->close();
                
                }
                

                but shows error

                ```Starting /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs...
                The program has unexpectedly finished.
                /opt/projects/Qt/computerized billing sysem/cbs/build-cbs-Desktop_Qt_5_7_0_GCC_64bit-Debug/cbs crashed.
                

                how to get rid of this.

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #7

                @rahulvishwakarma

                Does your this widget even have any parent? You don't check for nullptr.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                1 Reply Last reply
                2

                • Login

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