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

QAbstactItemDelegate is called with incorrect option rect from QListView

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 4.6.2
    • Widgets: Itemviews
    • None
    • Windows XP pro-64 (in 32 bits mode).

    Description

      I am trying to create a delegate to render data for the item view framework. The items can trade width for height in rendering. That makes me dependent on having correct information on the area that there is to use. QStyleOptionViewItem contains a rect member that is supposed to provide this information. Unfortunately, the value seems to be static when the call to QAbstractItemDelegate::sizeHint is made. Making the view wider does not result in an increased width for QStyleOptionViewItem::rect, while it does result in an increased rect for the actual paint call.

      On the other hand, if the view is made narrower, the supplied option rect in the paint call does not decrease. Instead, a horizontal scroll bar appears, even if the sizeHint supplied is narrower than the available space.

      When the view is a QListView, that only has a single column of data, I would have expected the option rect to supply the actual space that a QItemDelegate has available for rendering its data. If the scroll bar policy is to show scrolbars only when needed, it should first be set to the width of the contents rectangle (to try to fill the entire space). If it turns out that the sum of the returned heights is higher than the available vertical space, the first items should be re-queried for their size hint, but this time with a smaller width to accomodate for the vertical scroll bar. If the items return a sizeHint that is wider than the available space, a horizontal scroll bar should be used to accomodate that space. QListView should not decide on its own to make the items render themselves more widely than the available space.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            andre André Somers
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes