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. Two Message Boxes in a Row Positions Second One in an Odd Place
Forum Update on Monday, May 27th 2025

Two Message Boxes in a Row Positions Second One in an Odd Place

Scheduled Pinned Locked Moved Solved General and Desktop
qt4qmessageboxc++
5 Posts 2 Posters 1.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.
  • D Offline
    D Offline
    DougyDrumz
    wrote on 12 Jun 2017, 23:25 last edited by
    #1

    In my app all my messages are positioned in the middle of the main window unless I exec 2 in a row. The second one gets placed in the upper left hand corner of left monitor. The app is on the right monitor. This looks very odd and confuses the user. Any ideas?

    Dougy Drumz

    J 1 Reply Last reply 13 Jun 2017, 04:55
    0
    • D DougyDrumz
      12 Jun 2017, 23:25

      In my app all my messages are positioned in the middle of the main window unless I exec 2 in a row. The second one gets placed in the upper left hand corner of left monitor. The app is on the right monitor. This looks very odd and confuses the user. Any ideas?

      J Offline
      J Offline
      joeQ
      wrote on 13 Jun 2017, 04:55 last edited by
      #2

      @DougyDrumz hi, friend.

      I didn't clear well about what you problem. Can you show some code snippet or some screenshot?

      Just do it!

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DougyDrumz
        wrote on 13 Jun 2017, 16:37 last edited by
        #3

        Unfortunately my code is on a different, classified network. I.e., you can't get there from here. I'll see if I can be more clear:

        ...
        myQuestionbox = new  QMessageBox(this);
        ...
        int reply = myQuestionBox->exec();
        
        if (reply == QMessage::Yes)
        {
            resetConfirm();
        }
        ...
        
        void MyClass::resetConfirm()
        {
        
            ...
        
            int reply = myQuestionBox->exec();
        
            if (reply == QMessage::Yes)
            {
               doSomething();
            }
            ...    
        }
        

        When I call the first myQuestionBox->exec(), the QuestionBox is displayed in the center of the the main window, which is on the right monitor. When I call the second myQuestionBox->exec(), the QuestionBox is displayed in the upper left-hand corner of of the left monitor. In fact, any myQuestionBox I exec gets displayed in the center of the of the main window on the right monitor, unless the first myQuestionBox calls code which execs a second myQuestionBox. Then the second myQuestionBox gets displayed in the upper left-hand corner of the left monitor.

        Dougy Drumz

        J 1 Reply Last reply 14 Jun 2017, 04:25
        0
        • D DougyDrumz
          13 Jun 2017, 16:37

          Unfortunately my code is on a different, classified network. I.e., you can't get there from here. I'll see if I can be more clear:

          ...
          myQuestionbox = new  QMessageBox(this);
          ...
          int reply = myQuestionBox->exec();
          
          if (reply == QMessage::Yes)
          {
              resetConfirm();
          }
          ...
          
          void MyClass::resetConfirm()
          {
          
              ...
          
              int reply = myQuestionBox->exec();
          
              if (reply == QMessage::Yes)
              {
                 doSomething();
              }
              ...    
          }
          

          When I call the first myQuestionBox->exec(), the QuestionBox is displayed in the center of the the main window, which is on the right monitor. When I call the second myQuestionBox->exec(), the QuestionBox is displayed in the upper left-hand corner of of the left monitor. In fact, any myQuestionBox I exec gets displayed in the center of the of the main window on the right monitor, unless the first myQuestionBox calls code which execs a second myQuestionBox. Then the second myQuestionBox gets displayed in the upper left-hand corner of the left monitor.

          J Offline
          J Offline
          joeQ
          wrote on 14 Jun 2017, 04:25 last edited by
          #4

          @DougyDrumz

          do you have two monitors ?

          Why did not you use the QMessageBox static function or use the local QMessageBox variable?

          StandardButton 
          question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = StandardButtons( Yes | No ), StandardButton defaultButton = NoButton)
          

          if you must be use new QMessageBox, and you have two monitors. you can get the screens from QGuiApplication.

          [static] QList<QScreen *> QGuiApplication::screens()
          

          and then, you can to see QScreen public classes in Qt help. you can know screen size etc.

          at second exec , using move function. maybe it can successed.

          try it.

          Just do it!

          D 1 Reply Last reply 14 Jun 2017, 21:04
          0
          • J joeQ
            14 Jun 2017, 04:25

            @DougyDrumz

            do you have two monitors ?

            Why did not you use the QMessageBox static function or use the local QMessageBox variable?

            StandardButton 
            question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons = StandardButtons( Yes | No ), StandardButton defaultButton = NoButton)
            

            if you must be use new QMessageBox, and you have two monitors. you can get the screens from QGuiApplication.

            [static] QList<QScreen *> QGuiApplication::screens()
            

            and then, you can to see QScreen public classes in Qt help. you can know screen size etc.

            at second exec , using move function. maybe it can successed.

            try it.

            D Offline
            D Offline
            DougyDrumz
            wrote on 14 Jun 2017, 21:04 last edited by
            #5

            @joeQ As it turns out, I just tried the opposite. I had one newed Message Box for everything. In the place that had the funny location, I made a separate newed Message Box and it ended up in the correct place - the middle of its parent.

            Dougy Drumz

            1 Reply Last reply
            0

            1/5

            12 Jun 2017, 23:25

            • Login

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