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

Windows 11: QComboBox in QTreeWidget in QScrollArea turns completely black

XMLWordPrintable

    • Windows

      When a QComboBox is added as an item widget to a QTreeWidget, and the QTreeWidget itself is inside a QScollArea, clicking on the combo box on Windows 11 will turn the entire combo box black. This does not occur on Windows 10 or earlier, or on Linux or macOS.

      Code to reproduce:

      #include <QApplication>
      #include <QWidget>
      #include <QTreeWidget>
      #include <QTreeWidgetItem>
      #include <QComboBox>
      #include <QScrollArea>
      #include <QVBoxLayout>
      
      #include <memory>
      
      int main(int argc, char** argv) {
          QApplication app(argc, argv);
      
          QScrollArea window;
          window.setWindowTitle("Reproducer");
          
          QWidget* container = new QWidget();
          auto layout = new QVBoxLayout(container);
      
          window.setWidget(container);
          window.setWidgetResizable(true);
      
          auto treeWidget = new QTreeWidget(container);
          layout->addWidget(treeWidget);
          treeWidget->setColumnCount(2);
          treeWidget->setHeaderLabels({"Setting", "Value"});
      
          auto item1 = new QTreeWidgetItem();
          item1->setText(0, "Setting 1");
      
          treeWidget->addTopLevelItem(item1);
          
          auto combo1 = new QComboBox();
          combo1->addItem("Hello");
          combo1->addItem("World");
          combo1->addItem("Goodbye");
          
          treeWidget->setItemWidget(item1, 1, combo1);
          
          window.show();
          return app.exec();
      }
      

      After running this program, simply click on the combo box, it will show the drop down, but it will be entirely black (both the drop down and the combo box itself). The interaction with the combo box still works as expected (i.e. you can select the items if you guess where they are), but nothing is displayed.

      Screenshot before clicking:

      Screenshot after clicking:

      Screenshot after closing the dropdown:

      Resizing / repainting has no effect here once the QComboBox has entered this state. Other QComboBoxes in the same QTreeWidget are not affected until they are clicked themselves, but once each is clicked, they remain black.

      This might also affect other widgets than QComboBox.

      Note that the QTreeWidget must be in a QScrollArea itself (so basically double QScrollArea), otherwise this bug will not occur.

      This could be related to QTBUG-123722, where a change was reverted for Qt 6.7.0, but only for the non Windows 11 style, because the issue there could not be reproduced on Windows 11.

        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
            cseiler_lf Christian Seiler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes