Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, January 2007
MoveAction in a QTreeView with a subclass of QAbstractItemModel


Message 1 in thread

Hi,

I am trying to expand the simpletreemodel example with drag and drop of the
nodes. I want to be able to move the items inside of the tree. Now I have
the following problems:

1. If I return Qt::MoveAction in supportedDragActions() and
supportedDropActions() the drag starts but the drop does not work and is
indicated as impossible.

2. If I return Qt::MoveAction | Qt::CopyAction the move seems to work, but a
copy is not possible. dropMimeData() is always called with Qt::MoveAction
regardless how I drop the item. In contrast the view indicates that a copy
is performed by showing a + next to the dragged item.

3. If I start the application and click on the + next to 222 the subitem 23
appears. If I click on the 23, suddenly the item 111 is opened and the
subitems 11 and 14 appear.

I am using Qt 4.2.2 on linux. If you want to look at the problem, you can
find the code on http://www.pontohonk.de/example/modelview.cpp

You can see problem 1 by compiling the code and just dragging an item. To
see problem 2 add "| Qt::CopyAction" in the methods mentioned in problem 1
and try to copy an item by Drag&Drop. CopyAction should be the default and
pressing SHIFT during dragging should enable MoveAction. To see problem 3
just perform the indicated actions.

Greetings
Christoph Bartoschek

--
 [ signature omitted ]