[Qt-interest] How to re-lay out items in QListView on dataChanged()

Dmitry Teslenko dteslenko at gmail.com
Mon Apr 26 09:23:31 CEST 2010


> Hello!
>
> I have QListView in ItemView mode that shows previews of windows and
> window captions beneath.
> Windows are of different sizes, so my QListView's model provide data
> for Qt::DecorationRole and Qt::SizeHintRole.
>
> In scenario 1 I have all previews ready and after model reset QListView
> lays out all previews according its size hints.
>
> In scenario 2 I have only list of windows ready and worker threads preparing
> previews. After model reset QListView lays out previews stubs and waits.
> Thren previews are finally ready, model emits dataChanged() signals to
> notify QListView it's time to update previews. QListView re-reads previews
> from model and shows them nicely. Bad thing QListView doesn't also
> re-layout items and some of them looks cropped.
>
> How to trigger QListView item re-layout?


On Sat, Apr 24, 2010 at 00:55, Malyushytsky, Alex <alex at wai.com> wrote:
>>> How to trigger QListView item re-layout?
>
> I have not tried myself, but have you tried to call  doItemsLayout()?
>

Thanks for your interest. I've noticed layoutChanged() signal in docs.
doItemsLayout() by the way is not documented in docs.
It actually do what I've been asking for. But isn't it too expensive?

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?




More information about the Qt-interest-old mailing list