Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-41995

QMessageBox::addButton removes button - depending on whether QMessageBox::show was called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • 4.8.6, 5.4.0
    • None
    • Ubuntu 12.04 LTS 64 bit
      Windows 7 64 bit

      1. Have a simple MessageBox:
        QMessageBox msgBox;
        msgBox.setText("Hey yo!");
        msgBox.exec();
        
      2. Build and execute this:

        No surprises here.
      3. So far the MessageBox has only one button. Let's add another one:
        QMessageBox msgBox;
        msgBox.setText("Hey yo!");
        msgBox.addButton("Reject", QMessageBox::RejectRole);
        msgBox.exec();
        
      4. Build and execute this:

        Huh? Still only one button?
      5. Let's show the MessageBox before adding the button...
        QMessageBox msgBox;
        msgBox.setText("Hey yo!");
        msgBox.show();
        msgBox.addButton("Reject", QMessageBox::RejectRole);
        msgBox.exec();
        
      6. Build and execute this:

        So now there are both buttons??

      When I see a function named addButton, I expect it to add a button and nothing else. Above all, I don't expect that this removes a button.

      If there's a good reason for this behavior, then it should be documented clearly. Right now, this is not documented at all.

      I don't think that the behavior of addButton should depend on whether show was called or not.

        1. shown.png
          shown.png
          6 kB
        2. buttonadded.png
          buttonadded.png
          5 kB
        3. base.png
          base.png
          4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes