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

[REG 4->5.2] QMessageBox does not have button for closing if detailedText is set - addButton removes button

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.3.1
    • 5.2.1, 5.3.0
    • None
    • Ubuntu 12.04 LTS 64 bit
      Windows 7 64 bit
    • a149d2f73ec45084c589ef4211974ba50c0d4631. (4.6.2014, stable, 5.3.2?)

      Create a simple message box:

          QMessageBox msgBox;
          msgBox.setText("Hey yo!");
          msgBox.exec();
      

      It will look like this:

      Now add detailedText to the message box:

          QMessageBox msgBox;
          msgBox.setText("Hey yo!");
          msgBox.setDetailedText("Boring...");
          msgBox.exec();
      

      Now it will look like this:

      The "OK" button is gone. Pressing "Return" or "Escape" will show/hide the details.

      Even when detailed text is available, the dialog should always have a button for properly closing it. By default, this should be the "OK" button. Pressing "Escape" should never show more details.

      This is a regression as it works correctly in Qt 4.8.6 and 5.0.1.

      This can be worked around by passing QMessageBox::Ok to the message box' ctor.

      Update: This happens because calling QMessageBox::addButton removes the default button. Although this has already been the case in Qt 4.8.6, I think it is a bug because it is counter-intuitive and not even documented.

        1. withDetail.png
          5 kB
          Robert Löhning
        2. withoutDetail.png
          5 kB
          Robert Löhning
        3. qtbug39334.zip
          1 kB
          Friedemann Kleint
        For Gerrit Dashboard: QTBUG-39334
        # Subject Branch Project Status CR V

            kleint Friedemann Kleint
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes