[Interest] Model/Views and Drag&Drop actions

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Mon Mar 27 15:28:55 CEST 2017


Dear all,

I have two custom models associated with views and I would like to drag
from model A and drop into model B.

Model B has overloaded supportedDropActions and returns Qt::LinkAction

Model A has overloaded supportedDragActions and returns Qt::MoveAction |
Qt::LinkAction

This does not work as the cursor turns to a forbidden sign when dragging
over B.

If model A supportedDragActions returns Qt::LinkAction only, then this
works.



If I look to the source code of QAbstractItemViewPrivate, i find in
canDecode(QDropEvent * e):

            if (mime->hasFormat(modelTypes.at(i))
               && (e->dropAction() & model->supportedDropActions()))
                return true;

Which explains the issue, the event handler does not check the event's
possible drop actions and does not call setDropAction if the proposed
action is not supported.

Is this a bug or a feature?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170327/e1dd6d56/attachment.html>


More information about the Interest mailing list