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

Provide a convenience method in QStyledItemDelegate to draw a s tyled background

    XMLWordPrintable

Details

    Description

      A common pattern with custom item delegates is to draw a standard item background and then draw custom content on top. QItemDelegate in the past provided a drawBackground() method which could be used to do this. At the moment what I have done is copy the code from QStyledItemDelegate::paint() which casts the QStyleOptionViewItem to a suitable version, gets a suitable style using the associated widget or the application and then calls the QStyle::drawPrimitive() method. Since this is a common thing to want to do, a convenience method in QStyledItemDelegate would be useful.

      I had to look at the QStyledItemDelegate implementation to find out how to get the appropriate QStyle since QStyleOptionViewItemV3 (which provides the associated QWidget*) does not appear in the documentation. Please could you add a mention of this to the QStyledItemDelegate documentation and also a note of which style primitives are used to draw parts of the item (PE_PanelItemViewItem, CE_ItemViewItem).

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            admin Administrator
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes