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

windows11 style has QTableView ignoring Qt::ForegroundRole

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.7.3, 6.8.0 Beta2, 6.9.0 FF
    • 6.7.1, 6.7.2
    • Widgets: Styles
    • None
    • Windows 11 Version 23H2 (x86_64)
      Qt v6.7.2
      windows11 style
    • Windows
    • 7dc67d989 (dev), 41df8e68c (6.8), c52d0bfb0 (6.7)

    Description

      The intent is coloring QTableview text, in either Light or Dark mode, using an overridden data():

          else if (role == Qt::ForegroundRole)
          {
             return QBrush(QColor(Qt::blue)); // QColor(Qt::blue);

      With the "windows11" style, this Qt::ForegroundRole property appears to be ignored. The Qt::BackgroundRole is however accepted, like:

       

      When forcing use of the "fusion" style before initializing QApplication, i.e.

      QApplication::setStyle("fusion"); 

      the Qt::ForegroundRole property works as expected:

       

      • Removing the stylesheet on the QTableView::item didn't help.
      • QAbstractItemModelTester shows no warnings
      • a delegate viewer is active on some columns, but this affects all columns

      This came to my attention as 6.7.x defaults to "windows11". For now the app can keep using "fusion". Suggestions are welcome.

      Attachments

        Issue Links

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

          Activity

            People

              wladimir.leuschner Wladimir Leuschner
              wold5 W O
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes