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. QMessageBox not able to close.
Qt 6.11 is out! See what's new in the release blog

QMessageBox not able to close.

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 2.9k 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.
  • jsulmJ jsulm

    @Anas_Deshmukh How can you reach closePopUp() if you call

    int ret = this->msgBox->exec();
    

    in popUp() as exec() is a blocking call? How/where do you call closePopUp()?

    A Offline
    A Offline
    Anas_Deshmukh
    wrote on last edited by
    #4

    @jsulm Using qml timer sigal making closePopUp() as slot.
    please do refer main.qml part.

    jsulmJ 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Anas_Deshmukh How can you reach closePopUp() if you call

      int ret = this->msgBox->exec();
      

      in popUp() as exec() is a blocking call? How/where do you call closePopUp()?

      A Offline
      A Offline
      Anas_Deshmukh
      wrote on last edited by
      #5
      This post is deleted!
      1 Reply Last reply
      0
      • A Anas_Deshmukh

        @jsulm Using qml timer sigal making closePopUp() as slot.
        please do refer main.qml part.

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

        @Anas_Deshmukh Can you check what

        this->msgBox->close();
        

        returns?

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

        A 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Anas_Deshmukh Can you check what

          this->msgBox->close();
          

          returns?

          A Offline
          A Offline
          Anas_Deshmukh
          wrote on last edited by
          #7

          @jsulm it return true in all scenario (either successfully close or not close at all).

          JonBJ 1 Reply Last reply
          0
          • A Anas_Deshmukh

            @jsulm it return true in all scenario (either successfully close or not close at all).

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #8

            @Anas_Deshmukh
            Although I doubt it will help your behaviour --- though worth a try --- you might like to replace this->msgBox->close(); with something like this->msgBox->reject(); or this->msgBox->done(-1);, to aid your caller.

            A 1 Reply Last reply
            0
            • JonBJ JonB

              @Anas_Deshmukh
              Although I doubt it will help your behaviour --- though worth a try --- you might like to replace this->msgBox->close(); with something like this->msgBox->reject(); or this->msgBox->done(-1);, to aid your caller.

              A Offline
              A Offline
              Anas_Deshmukh
              wrote on last edited by
              #9

              @JonB hi tried but both but nothing work.

              if(this->msgBox->isEnabled() )  // this condition is still true even after using reject and done.
              
              JonBJ 1 Reply Last reply
              0
              • A Anas_Deshmukh

                @JonB hi tried but both but nothing work.

                if(this->msgBox->isEnabled() )  // this condition is still true even after using reject and done.
                
                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #10

                @Anas_Deshmukh
                Like I said, I did not expect this change to help your issue now. But I think you will want it when you have your code working, since you test the result returned from the dialog.

                Never mind whether this->msgBox->isEnabled() is still true, does the dialog actually close or not?

                A 1 Reply Last reply
                0
                • JonBJ JonB

                  @Anas_Deshmukh
                  Like I said, I did not expect this change to help your issue now. But I think you will want it when you have your code working, since you test the result returned from the dialog.

                  Never mind whether this->msgBox->isEnabled() is still true, does the dialog actually close or not?

                  A Offline
                  A Offline
                  Anas_Deshmukh
                  wrote on last edited by
                  #11

                  @JonB Not close.

                  JonBJ 1 Reply Last reply
                  0
                  • A Anas_Deshmukh

                    @JonB Not close.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #12

                    @Anas_Deshmukh
                    Well, I'd try inserting a single-shot timer for 1 second which will close the message box immediately before your .exec() line, to eliminate whatever might be going on with your QML timer stuff. There are plenty of examples on the web of doing that for timed closure of a dialog. And/or change your .exec() to .show() (have to adjust your calling code) and see whether that makes it work.

                    A 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @Anas_Deshmukh
                      Well, I'd try inserting a single-shot timer for 1 second which will close the message box immediately before your .exec() line, to eliminate whatever might be going on with your QML timer stuff. There are plenty of examples on the web of doing that for timed closure of a dialog. And/or change your .exec() to .show() (have to adjust your calling code) and see whether that makes it work.

                      A Offline
                      A Offline
                      Anas_Deshmukh
                      wrote on last edited by Anas_Deshmukh
                      #13

                      @JonB Hi, i fix the problem.
                      Issue i had is somehow in my project one new object were created (typical scenario), and function closePopUp() unable to access newly created instance as it always pointing previously created object.

                      thaks for your time and consideration.

                      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