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

Behaviour change Qt 6.5->Qt 6.6 QDialogButtonBox::button()->setVisible(false) deletes button

    XMLWordPrintable

Details

    • a7cb7dad789849724767bd49eca8958d02eb2277

    Description

      When setting a QPushButton in a QDialogButtonBox to invisible, the button used to just not be visible in up to Qt 6.5. In Qt 6.6, the button seems to get deleted, which can cause nullptr access in preexisting code that uses QDialogButtonBox .

      Reproducer
      #include <QApplication>
      #include <QDialogButtonBox>
      #include <QPushButton>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QDialogButtonBox box(QDialogButtonBox::Ok);
      
          qDebug() << box.button(QDialogButtonBox::Ok);
          box.button(QDialogButtonBox::Ok)->setVisible(false);
          qDebug() << box.button(QDialogButtonBox::Ok);
      
          return 0;
      }
      

      Use code snippet into Qt Creator

      Output under Qt 6.5.2
      QPushButton(0x23b073e1710)
      QPushButton(0x23b073e1710)
      
      Output under Qt 6.6
      QPushButton(0x2c258b26570)
      QWidget(0x0)
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              axelspoerl Axel Spoerl
              portale Alessandro Portale
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes