[Qt-interest] QListView and item size
Anthony Serdyukov
uksus70 at gmail.com
Thu Dec 25 09:41:46 CET 2008
I have found a task related to my question.
http://trolltech.com/developer/task-tracker/index_html?method=entry&id=152446
---------------------------------
Description
When emitting dataChanged in the attached model with altered
Qt::SizeHintRole, the view doesn't update it's items' sizes and
consequently not the scrollbars of the viewport.
Rejected:
The sizeHint is used when laying out the items in the view. To trigger
a new layout, either emit layoutChanged from the model or call
schedultDelayedLayout in the view.
In Qt 4.3 QListView will change the size of the items when the data
changes, if the items are movable.
----------------------------------
Seems like it's true for Qt 4.4.3
2008/12/25 Anthony Serdyukov <uksus70 at gmail.com>:
> Good day.
>
> Having QListView and a custom model.
> Model responds on Qt::DisplayRole and Qt::DecorationRole.
> View is in QListView::IconMode and the layout mode is QListView::Batched.
>
> First, view tries to get Qt::SizeHintRole. Since my model returns
> QVariant() for this role, view calculates the size itself, taking into
> account item's text and icon.
>
> During program flow the icons for items are changed, and new icon has
> different size (larger, for example). Model emits dataChanged() signal
> and new icons are displayed by the view.
> But the size of item does not change until user resize view. So, the
> layout is broken at this moment.
>
> Why does not the view recalculate the size of the item when the icon
> changes? And how to solve the problem?
>
> --
> Regards,
> Anthony
>
--
Regards,
Anthony
More information about the Qt-interest-old
mailing list