[Qt-qml] How-to re-order Items inside a ListView with drag and drop?
Martin Jones
martin.jones at nokia.com
Tue Jul 6 06:41:57 CEST 2010
On Tue, 6 Jul 2010 02:06:51 pm ext Gregory Schlomoff wrote:
> Hi guys,
>
> I'm trying to create a ListView where items can be re-ordered with
> drag and drop. Basically, the QML equivalent of this javascript / css
> demo : http://www.wil-linssen.com/demo/jquery-sortable-ajax/
>
> What are your thoughts on this?
>
> 1. Is it feasible in pure QML? It seems that ListView doesn't like
> draggable items: as soon as one tries to drag an item, it jumps to the
> top of the list.
ListView owns the delegates, and is in full control of their positioning. My
suggestion is to not attempt to move the actual delegate, but rather have the
delegate contain a draggable Item that can be reparented and moved around
without affecting the positioning of the delegate as far as the ListView is
concerned.
> 2. Should this behavior of draggable items jumping to the top of the
> ListView when one tries to drag them be considered a bug ?
I don't know exactly what you're doing so I can't really say. Code would
help. If I were to guess, I'd say that you're messing with items that the
ListView positions and in that case the behavior is undefined.
> 3. Should I subclass the QDeclarativeListVIew and make my own ListVIew
> with drag and drop support?
I'd advise against that. I think this is possible via QML. You just need to
be careful about only interacting with the view via the model - i.e. don't
move its instantiated delegates directly.
> 4. Can the ability to reorder items with drag and drop inside a
> ListView (or a GridView, for that matter) be considered a feature
> request for QML ?
It can be, but will definitely not be implemented for Qt 4.7
--
Martin
More information about the Qt-qml
mailing list