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

Applying a style to QTreeView::item or QTableView::item causes the background returned from the model to be lost

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.8.5
    • Widgets: Style Sheets
    • None
    • Building 64bit.
      Tested on 64-bit windows 7 and RH linux.

    Description

      Hi, I am writing QTreeView that is working with QAbstractItemModel. Normally, the data returned from model().data() takes highest priority, i.e. it overrides everything that is specified by style or inherited from parent controls.

      However, if I apply any style to QTreeView::item (the same is true if I use QTableView), the background returned from the model is ignored.

      Attached a simple example, if you run it as is, it will show a small grid with black, red, green and yellow cells.
      However, if you uncomment the a.setStyleSheet(...) line, all backgrounds are gone.

      Note, the style has nothing to do with background, however even if it had, IMHO the background from the model should take precedence.

      Note, in my case somewhere deep in the QStyleSheet code, depending on whether the style is applied to the item, either QWindowsStyle::drawControl or baseStyle()->drawControl is called - in my case, when no style is applied, baseStyle() returns QWindowsVistaStyle. Hope it helps a bit...

      Please fix (or let me know which version fixes it)...

      Thanks!!!

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            sergeyc Serge
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes