Gopalakrishna Palem
Gopalakrishna Palem

Reputation: 1715

Qt - How to force the drop action to be copyaction when the drop location is some other application

I have subclassed QMimeData and drag&drop works perfectly fine within my widget – for both copyAction and MoveAction, Data gets copied and moved as needed (based on shift / ctrl keys etc.)

For compatibility I am supporting other simple formats such as text/plain – the major problem is, I cannot allow ‘move’ operation for the drops to other applications for these compatible formats.

For example, I allow my data to be dropped from my widget to some textbox – but only as long as it is a ‘copyAction’. But, I do not see any way of forcing this.

Question: How to force the drop action to be ‘copy action’ for all external widgets, while allowing the copy/move within my widget?????

By 'force' it is meant no matter what user chooses (ctrl, shift or whatever) - my data should always get 'copied' and not 'moved' when the drag happens for compatible formats. (while it should allow copy and move for its native format)

How to enforce this in Qt?

Upvotes: 4

Views: 1684

Answers (1)

ulatekh
ulatekh

Reputation: 1490

This appears to be a limitation in Qt. This post describes the issue and shows that the problem is in QAbstractItemView::startDrag(). Essentially, Qt doesn't directly let you drag both internally to the same widget, and to an external application.

Upvotes: 1

Related Questions