PDA

View Full Version : MoveAction in a QTreeView with a subclass of QAbstractItemModel



ponto
30th January 2007, 12:36
Hi,

I've asked the question on the qt-interest mailinglist but got no answer.

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
I can also paste the code if this is wanted.

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.

ponto
2nd February 2007, 09:42
Is here anyone that can reproduce the problems on his system? Maybe this is only a compiler/platform issue.