[Interest] Quick2 - animate sorting of listview, sorted with QSortFilerProxyModel

André Somers andre at familiesomers.nl
Wed Aug 14 16:41:34 CEST 2013


Op 14-8-2013 10:34, Ola Røer Thorsen schreef:
> I'd like to animate the sorting of a live scoreboard, using Quick2 and
> c++. It's for covering a live sports racing event, but the same would
> apply if you imagine you have to create the score board for the voting
> segment of the Eurovision Song Contest or something.
>
> My data model is based on QAbstractListModel, and I sort it using the
> QSortFilterProxyModel. Finally it's displayed in a Quick2 ListView.
>
> I think I might have hit a severe limitation in ListView or something,
> it does not seem to grasp the re-ordering of elements in the list, it
> just thinks the contents of each entry changed instead. So the item on
> the top of the list always has index 0, etc. This prevents animation of
> re-ordering, only animation of adding/removing elements on the end of
> the list is possible.
>
> Same issue occurs when filtering a list, it's not the items filtered out
> that really disappear from the list, it's just the ones that happen to
> be on the bottom.
>
> Anyone know how to animate the sorting of a ListView? (hopefully without
> Javascript hacks...)
>
> Thanks!
>
Indeed, as Mark said: interesting question. Thanks for asking.

I think the root of the problem is that QAbstractItemModel does not have 
a concept of moving items, while the native QML model does. The problem 
is: I don't think you can officially use the native QML model, as it is 
private API (last time I looked, anyway). Perhaps you could use it 
anyway, taking the risk that your application won't work anymore with 
another Qt version, but I have not looked at the API of the QML model 
myself to see what you can do with it from C++ code.

André

-- 
You like Qt?
I am looking for collegues to join me at i-Optics!




More information about the Interest mailing list