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 exec only returns 1024 or 4194304...
Forum Updated to NodeBB v4.3 + New Features

QMessageBox exec only returns 1024 or 4194304...

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 697 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.
  • P Offline
    P Offline
    Paddle
    wrote on last edited by Paddle
    #1

    I can't find any reference to such issue. I'm trying to add a QMessageBox and the exec function is returning me only 1024 if I click ok or 4194304 if I click cancel. I commented out lines that I initially used but don't change the situation if commented out.

       QMessageBox restartBox(this);
        restartBox.setIcon(QMessageBox::Warning);
        restartBox.setWindowTitle(tr("Restart required"));
        restartBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
    
        int exec = restartBox.exec();
        Base::Console().Warning("exec %d", exec);
    
        if (exec == QDialog::Accepted) {/*never triggered*/}
    

    Any idea what can trigger such behavior?

    SGaistS B 2 Replies Last reply
    0
    • P Paddle

      I can't find any reference to such issue. I'm trying to add a QMessageBox and the exec function is returning me only 1024 if I click ok or 4194304 if I click cancel. I commented out lines that I initially used but don't change the situation if commented out.

         QMessageBox restartBox(this);
          restartBox.setIcon(QMessageBox::Warning);
          restartBox.setWindowTitle(tr("Restart required"));
          restartBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
      
          int exec = restartBox.exec();
          Base::Console().Warning("exec %d", exec);
      
          if (exec == QDialog::Accepted) {/*never triggered*/}
      

      Any idea what can trigger such behavior?

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      QMessageBox::exec returns a QMessageBox::StandardButton.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Paddle

        I can't find any reference to such issue. I'm trying to add a QMessageBox and the exec function is returning me only 1024 if I click ok or 4194304 if I click cancel. I commented out lines that I initially used but don't change the situation if commented out.

           QMessageBox restartBox(this);
            restartBox.setIcon(QMessageBox::Warning);
            restartBox.setWindowTitle(tr("Restart required"));
            restartBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
        
            int exec = restartBox.exec();
            Base::Console().Warning("exec %d", exec);
        
            if (exec == QDialog::Accepted) {/*never triggered*/}
        

        Any idea what can trigger such behavior?

        B Offline
        B Offline
        Bonnie
        wrote on last edited by
        #3

        @Paddle Please read the documentation of QMessageBox::exec():

        When using a QMessageBox with standard buttons, this function returns a StandardButton value indicating the standard button that was clicked.

        So it returns QMessageBox::Ok = 0x00000400 = 1024, or QMessageBox::Cancel = 0x00400000 = 4194304.

        P 1 Reply Last reply
        0
        • B Bonnie

          @Paddle Please read the documentation of QMessageBox::exec():

          When using a QMessageBox with standard buttons, this function returns a StandardButton value indicating the standard button that was clicked.

          So it returns QMessageBox::Ok = 0x00000400 = 1024, or QMessageBox::Cancel = 0x00400000 = 4194304.

          P Offline
          P Offline
          Paddle
          wrote on last edited by Paddle
          #4

          Oh I was reading the exec() function in QDialog documentation page... I haven't seen it was reimplemented in QMessageBox. Sorry about that.

          SGaistS 1 Reply Last reply
          0
          • P Paddle

            Oh I was reading the exec() function in QDialog documentation page... I haven't seen it was reimplemented in QMessageBox. Sorry about that.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #5

            @Paddle ni worries !

            Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            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