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

[Qt 6.2.2 -> 6.2.3] QPalette::setBrush changes behavior, child widgets may have wrong color.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Won't Do
    • Affects Version/s: 6.2.3
    • Fix Version/s: None
    • Component/s: GUI: Painting
    • Labels:
      None

      Description

      In Qt 6.2.3, QPalette::setBrush does not mark a color role as "modified" if the set brush corresponds to what the palette had, before.

      This can cause that in a nested widget scenario, the child widget fails to set its individual palette.

      Example:

      #include <QApplication>
      #include <QPalette>
      #include <QVBoxLayout>
      #include <QWidget>
      
      void setThemePalette()
      {
          QPalette themePalette;
          themePalette.setColor(QPalette::Window, Qt::red);
          QApplication::setPalette(themePalette);
      }
      
      int main(int argc, char *argv[])
      {
          setThemePalette();
          QApplication a(argc, argv);
      
          /*
      
          Expected result:
      
            +--------------------+
            | w1 (Qt::green)     |
            |  +--------------+  |
            |  | w2 (Qt::red) |  |
            |  +--------------+  |
            |                    |
            +--------------------+
      
          */
      
          QWidget w1;
          QPalette p1;
          p1.setColor(QPalette::Window, Qt::green);
          w1.setPalette(p1);
      
          auto w2 = new QWidget;
          QPalette p2;
          p2.setColor(QPalette::Window, Qt::red);
          w2->setPalette(p2);
          w2->setAutoFillBackground(true);
          w2->setMinimumSize(100, 100);
      
          auto layout = new QVBoxLayout(&w1);
          layout->addWidget(w2);
          w1.show();
      
          return a.exec();
      }
      

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-100439
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              vhilshei Volker Hilsheimer
              Reporter:
              portale Alessandro Portale
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes