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

QTableWidget foreground / font color cannot be set via palette on Win11

    XMLWordPrintable

Details

    • Windows
    • 7dc67d989 (dev), 41df8e68c (6.8), c52d0bfb0 (6.7)

    Description

      When trying to set the font/foreground color in QTableWidget via Palette (see TableColor.zip),
      either for all entries

          QPalette pal=table1->palette();
          pal.setColor(QPalette::ColorRole::Text, QColor::fromRgb(255,0,0));
          table1->setPalette(pal);

          for(int i=0;i<rowTexts.size(); i++)
          {
              QTableWidgetItem* item = new QTableWidgetItem(rowTexts[i]);
              table1->setItem(i,0,item);
      {{    }}}

      or single cells

          for(int i=0;i<rowTexts.size(); i++)
          {
              QTableWidgetItem* item = new QTableWidgetItem(rowTexts[i]);
              item->setForeground(QColor::fromRgb(i*60+80,0,0));
              table2->setItem(i,0,item);
      {{    }}}
         
      this has no effect on Windows 11 (see TableColor_Win11_not_ok.png), the text stays black.
      On Windows 10 everything is ok (see TableColor_Win10_ok.png).

      In fact, the problem occurs only in the combination Qt6(.7.2) + Win11 + Palette.
      With Qt5 or Win10 or StyleSheets, it works. Unfortunately, setStyleSheet() is not available for table items.

      Attachments

        Issue Links

          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
              daniel_frey Daniel Frey
              Votes:
              3 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes