[Interest] Very vague QML ListView issue
Bradley Smith
bradley at baysmith.com
Thu May 24 06:54:39 CEST 2012
I believe the reason you can drag an item up but not down in the
ListView is because the item being dragged is interfering with the
dataView.indexAt(mouseX, mouseY). It appears that the items in the
ListView are searched in order. Since the drag item moves with the
mouse, it is always under the mouse and always the first item found
since it precedes later items which might also be under the mouse.
One solution to this problem is to move the drag target imperceptibly
in x and only use y for indexAt. For example, add "currentItem.x =
0.001" to onPressed, and change "var tempIndex =
dataView.indexAt(mouseX, mouseY)" to "var tempIndex =
dataView.indexAt(0, mouseY)"
I've seen other drag reordering of ListView solutions, but they
usually move the item being dragged, and thus don't have the same
problem with use of indexAt.
Bradley
More information about the Interest
mailing list