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

[REG Qt 6.9.2] Style Sheet is not always applied to children

XMLWordPrintable

    • All
    • 14aa698cc (dev), 9dcb39044 (6.10)

      Sometimes style sheet is not applied to child widgets.

       

      Example application:

      #include <QtWidgets>
      
      using namespace Qt::StringLiterals;
      
      class MyWidget : public QWidget
      {
          Q_OBJECT
      
      public:
          MyWidget()
          {
              auto lw = new QListWidget;
      
              auto lwi = new QListWidgetItem;
              lw->addItem(lwi);
              lw->setItemWidget(lwi, new QLabel(u"test"_s));
      
              auto l = new QVBoxLayout(this);
              l->addWidget(lw);
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          a.setStyle(u"Fusion"_s);
      
          a.setStyleSheet(u"MyWidget QLabel {color:red;}"_s);
      
          MyWidget w;
          w.show();
      
          return a.exec();
      }
      
      #include <main.moc>
      

       

      Result (Qt 6.9.2): Text is white (dark mode), style is not applied.
      Expected result (Qt 6.9.1 and older): Text is red.

      Caused by: QTBUG-133332

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

            chehrlic Christian Ehrlicher
            zaps166 Błażej Szczygieł
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes