[PyQt] possible to change the execute drag type?

danny shevitz at lanl.gov
Tue Oct 26 18:03:10 BST 2010


Howdy,

I'm trying to use default drag and drop within a QTreeView. In my application,
I want to interpret dragging as "move below" and ctrl-dragging (Qt.CopyAction)
as "insert previous before as sibling". I have overridden dropMimeData and
the insertion part works just fine. 

The problem is that the framework (in QAbstractItemView::startDrag) does this

if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction)
  d->clearOrRemove(); 

So, the framework thinks I have done a Qt::CopyAction and doesn't remove the
original row. 

Does anyone know how to modify the QDrag executed_action (in C++) so that the
drag reports back that it has been moved, not copied. The QDrag API doesn't seem
to allow direct modification of the executed_action member.

Setting allowed drag operation flags won't work. I want the drop to be
interpreted as a copy so I can change the position behavior, but get reported
back to the framework as a
move, so the original row gets deleted.

thanks,
Danny



More information about the PyQt mailing list