Model Drag'n'Drop - Default Move
The QT reference article on models subclassing says that
Quote:
However, it is also possible to customize the way items are encoded during drag and drop operations, whether they are copied or moved by default, and how they are inserted into existing models.
but I cannot find any evident way of setting the default drag/drop action to move and disabling the copy operation at all since there's no "copy" in my app.
Can someone give me a hint?
Thanks!
Re: Model Drag'n'Drop - Default Move
Hello Lemming,
I was facing the same problem a few days ago and to be short I don't find a way to solve this on the model side.
The model provides a method to tell which drop actions are supported:
This method must be overwritten and return Qt::MoveAction, so the model won't accept any "CopyDrops".
On the drag-site there is the method
which can be used to set the supported actions. These actions are queried by the view when a drop is started using QAbstractItemModel::supportedDragActions(), but somehow this doesn't work as expected, the standard list or tree view always creates a "CopyDrop", and I didn't find a way to prevent this.
The only thing you can do is to subclass the view you are using and overwrite the startDrag method, and force it to make a Qt::MoveAction when the drag event starts.
The above mentioned methods were introduced in qt-4.2 and I was trying with 4.2.1.
Hope it helps.
Re: Model Drag'n'Drop - Default Move
Quote:
Originally Posted by
ggrinder
The only thing you can do is to subclass the view you are using and overwrite the startDrag method, and force it to make a Qt::MoveAction when the drag event starts.Hope it helps.
That's exactly what I was thinking about but decided to leave for "Plan B".
Looks like I'll have to ask the Trolltech support...