Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.6.2
-
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.