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

QComboBox custom popup not visible if ComboBox is inside a QScrollArea

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.0, 6.8.0
    • Widgets: Style Sheets
    • None
    • Windows

    Description

      Setting the background via StyleSheets on a QComboBox or "QComboBox QAbstractItemView" in combination with `setView` leads to the popup not showing at all on windows if inside a QScrollArea.

      Everything works as expected if NOT in a QScrollArea and without changing the background via stylesheets.
      Potentially related to https://bugreports.qt.io/browse/QTBUG-123722

      Tested with "Fusion" and Windows11 styles.
      I did not yet test other versions besides 6.5.1 where this worked without any issues.

      Reproducible example

      #include <QApplication>
      #include <QTableWidget>
      #include <QComboBox>
      #include <QVBoxLayout>
      #include <QLabel>
      #include <QScrollArea>
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          a.setStyle("Fusion");
          a.setStyleSheet("QComboBox QAbstractItemView { background: red; }");
          QComboBox *box = new QComboBox();
          QTableWidget *table = new QTableWidget();
          table->setColumnCount(2);
          table->setRowCount(10);
          box->setModel(table->model());
          box->setView(table);
          QComboBox *box2 = new QComboBox();
          for(int i = 0; i < 10; ++i){
              QTableWidgetItem *itm = new QTableWidgetItem();
              itm->setData(Qt::DisplayRole, "asd");
              table->setItem(i, 0, itm);
              table->setItem(i, 1, new QTableWidgetItem(" - var"));
              box2->addItem("qwe");
          }
          QFrame *frame = new QFrame();
          QVBoxLayout *l = new QVBoxLayout(frame);
          l->addWidget(new QLabel("Pre"));
          l->addWidget(box);
          l->addWidget(box2);
          l->addWidget(new QLabel("Post"));
          QScrollArea *area = new QScrollArea();
          area->setWidget(frame);
          area->show();
          return a.exec();
      }
      
      

       

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            sleepprogger peter lustig
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes