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. Beginner question: How to tell when Dialog is exposed?

Beginner question: How to tell when Dialog is exposed?

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 5 Posters 4.0k Views 1 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.
  • mstothM mstoth

    Yes, the dialog invokes another dialog both of which are full screen (on a beaglebone). Once the covering dialog goes away the focus is returned to the covered dialog which is now exposed. If I try to use focusInEvent however, this routine does not get called when the first dialog is exposed.

    Pablo J. RoginaP Offline
    Pablo J. RoginaP Offline
    Pablo J. Rogina
    wrote on last edited by
    #4

    @mstoth how are you displaying the dialogs, in particular the second one?
    From documentation:

    The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will provide a useful return value.

    Upvote the answer(s) that helped you solve the issue
    Use "Topic Tools" button to mark your post as Solved
    Add screenshots via postimage.org
    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    1
    • mstothM Offline
      mstothM Offline
      mstoth
      wrote on last edited by mstoth
      #5

      These are not modal.
      In the first dialog, the onRelease handler for one of the buttons is

      void MainMenu::on_configureConsoleButton_released()
      {
          dc=new DialogConsoleConfigA(this);
          dc->show();
      }
      

      DialogConsoleConfigA covers the main menu dialog.
      Then when DialogConsoleConfigA is removed,

      void DialogConsoleConfigA::on_pushButton_released()
      {
          this->hide();
      }
      
      

      Now the first dialog is exposed again. I need to find a way for the MainMenu dialog to be aware that the DialogConsoleConfigA dialog has been hidden.

      Taz742T DiracsbracketD 2 Replies Last reply
      0
      • mstothM mstoth

        These are not modal.
        In the first dialog, the onRelease handler for one of the buttons is

        void MainMenu::on_configureConsoleButton_released()
        {
            dc=new DialogConsoleConfigA(this);
            dc->show();
        }
        

        DialogConsoleConfigA covers the main menu dialog.
        Then when DialogConsoleConfigA is removed,

        void DialogConsoleConfigA::on_pushButton_released()
        {
            this->hide();
        }
        
        

        Now the first dialog is exposed again. I need to find a way for the MainMenu dialog to be aware that the DialogConsoleConfigA dialog has been hidden.

        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by Taz742
        #6

        @mstoth
        use signal slot mechanism.

        Dialog *dialog = new Dialog;
        connect(dialog, &Dialog::rejected, this, [=](){
            //something
        });
        dialog->show();
        

        or in your Dialog class listen a closeEvent:

        void Dialog::closeEvent (QCloseEvent *event) {
             emit closed();
        event->accept();
        }
        

        .h file:

        signals:
        void closed();
        
        protected:
        void closeEvent(QCloseEvent *event);
        
        Dialog *dialog = new Dialog;
        connect(dialog, &Dialog::closed, this, [=](){
            //something
        });
        dialog->show();
        

        Do what you want.

        DiracsbracketD 1 Reply Last reply
        2
        • mstothM mstoth

          These are not modal.
          In the first dialog, the onRelease handler for one of the buttons is

          void MainMenu::on_configureConsoleButton_released()
          {
              dc=new DialogConsoleConfigA(this);
              dc->show();
          }
          

          DialogConsoleConfigA covers the main menu dialog.
          Then when DialogConsoleConfigA is removed,

          void DialogConsoleConfigA::on_pushButton_released()
          {
              this->hide();
          }
          
          

          Now the first dialog is exposed again. I need to find a way for the MainMenu dialog to be aware that the DialogConsoleConfigA dialog has been hidden.

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #7
          This post is deleted!
          1 Reply Last reply
          0
          • Taz742T Taz742

            @mstoth
            use signal slot mechanism.

            Dialog *dialog = new Dialog;
            connect(dialog, &Dialog::rejected, this, [=](){
                //something
            });
            dialog->show();
            

            or in your Dialog class listen a closeEvent:

            void Dialog::closeEvent (QCloseEvent *event) {
                 emit closed();
            event->accept();
            }
            

            .h file:

            signals:
            void closed();
            
            protected:
            void closeEvent(QCloseEvent *event);
            
            Dialog *dialog = new Dialog;
            connect(dialog, &Dialog::closed, this, [=](){
                //something
            });
            dialog->show();
            
            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by
            #8

            @Taz742 said in Beginner question: How to tell when Dialog is exposed?:

            connect(dialog, &Dialog::rejected, this, =

            Hi, why rejected?

            Taz742T 1 Reply Last reply
            0
            • DiracsbracketD Diracsbracket

              @Taz742 said in Beginner question: How to tell when Dialog is exposed?:

              connect(dialog, &Dialog::rejected, this, =

              Hi, why rejected?

              Taz742T Offline
              Taz742T Offline
              Taz742
              wrote on last edited by
              #9

              @Diracsbracket
              When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal ?

              Do what you want.

              DiracsbracketD 1 Reply Last reply
              0
              • Taz742T Taz742

                @Diracsbracket
                When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal ?

                DiracsbracketD Offline
                DiracsbracketD Offline
                Diracsbracket
                wrote on last edited by Diracsbracket
                #10

                @Taz742 said in Beginner question: How to tell when Dialog is exposed?:

                When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal

                Yes, but when you reject a config dialog, then that usually means nothing needs to be done...? I would have used the accepted() signal. But hey, let's wait and see what exactly @mstoth has in mind.

                Taz742T 1 Reply Last reply
                1
                • DiracsbracketD Diracsbracket

                  @Taz742 said in Beginner question: How to tell when Dialog is exposed?:

                  When form 'X' button click, when a dialog is closed QDialog does not call a rejected signal

                  Yes, but when you reject a config dialog, then that usually means nothing needs to be done...? I would have used the accepted() signal. But hey, let's wait and see what exactly @mstoth has in mind.

                  Taz742T Offline
                  Taz742T Offline
                  Taz742
                  wrote on last edited by Taz742
                  #11

                  @Diracsbracket
                  I think no one is right, he only wants to hide the dialog? Waiitt ))

                  Do what you want.

                  DiracsbracketD 1 Reply Last reply
                  0
                  • Taz742T Taz742

                    @Diracsbracket
                    I think no one is right, he only wants to hide the dialog? Waiitt ))

                    DiracsbracketD Offline
                    DiracsbracketD Offline
                    Diracsbracket
                    wrote on last edited by
                    #12

                    @Taz742 said in Beginner question: How to tell when Dialog is exposed?:

                    he only wants to hide the dialog

                    @mstoth said in Beginner question: How to tell when Dialog is exposed?:

                    when that second panel goes away, my first dialog needs to check a parameter

                    I think he wants to check if any of the settings were changed when the dialog was closed^^. In any case, thanks for posting the solution!

                    1 Reply Last reply
                    0
                    • mstothM Offline
                      mstothM Offline
                      mstoth
                      wrote on last edited by mstoth
                      #13

                      Indeed, all I need to do is see if something has happened when the first dialog is visible again. I thought about signals/slots but there is more than one case where this first dialog becomes visible again. For instance, the first dialog has 6 buttons, each presents a different new dialog. When any of those appear, they hide the first one. To use signals, i'd have to connect to each of those 6 dialogs.

                      I was hoping for something more elegant like a event handler I could override in the first dialog that gets called when the first dialog becomes visible again. (something like onExposed()) . I have not seen anything like that.

                      Thanks by the way for all the help! I appreciate your thoughts.

                      Taz742T 1 Reply Last reply
                      0
                      • mstothM mstoth

                        Indeed, all I need to do is see if something has happened when the first dialog is visible again. I thought about signals/slots but there is more than one case where this first dialog becomes visible again. For instance, the first dialog has 6 buttons, each presents a different new dialog. When any of those appear, they hide the first one. To use signals, i'd have to connect to each of those 6 dialogs.

                        I was hoping for something more elegant like a event handler I could override in the first dialog that gets called when the first dialog becomes visible again. (something like onExposed()) . I have not seen anything like that.

                        Thanks by the way for all the help! I appreciate your thoughts.

                        Taz742T Offline
                        Taz742T Offline
                        Taz742
                        wrote on last edited by
                        #14

                        @mstoth
                        Good! I think you have an idea of what to do. Then mark this topic to be solved.

                        Do what you want.

                        1 Reply Last reply
                        0
                        • mstothM Offline
                          mstothM Offline
                          mstoth
                          wrote on last edited by
                          #15

                          ok, so my solution is to use signals to indicate the condition i'm interested in. It's a bit messy since there are so many places I need to connect to but from what I'm hearing, that is the only way.

                          I'll mark it as solved but unfortunately it is not the kind of solution I was hoping for. If anyone else has a more elegant way of handling this feel free to let me know.

                          I do appreciate everyone's time and effort on this problem! Thank you very much.

                          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