how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?
-
Hi,
Start by having a look at the Drag & Drop documentation
-
i know how to darg beteen widget. but i don't know how can i
how to Drag&Drop a file from windows(eg.Window Resource Manager) into QTreeWidget?@opengpu2 You can find good example "Drop site example" in QtCreator. You know how to read? Read again documentation please:
Interoperating with Other Applications
On X11, the public XDND protocol is used, while on Windows Qt uses the OLE standard, and Qt for OS X uses the Cocoa Drag Manager. On X11, XDND uses MIME, so no translation is necessary. The Qt API is the same regardless of the platform. On Windows, MIME-aware applications can communicate by using clipboard format names that are MIME types. Already some Windows applications use MIME naming conventions for their clipboard formats.
Custom classes for translating proprietary clipboard formats can be registered by reimplementing QWinMime on Windows or QMacPasteboardMime on OS X.
-
Hi,
Start by having a look at the Drag & Drop documentation
-
and i noticed: i have to add drag->exec(); int the ::startDrag.
as i search all the examples, i found drag->exec(); can be in (1)::startDrag, (2)::mousePress, (3)::mouseMove.......what is the different?and i found code like this:
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
i don't quite understand the meaning of Qt::DropAction...
as there can be if (drag->exec(Qt::MoveAction) == Qt::MoveAction) {......}
what does it mean? -
Drop action: you can for example move an item or copy it e.g. move a file from a folder to another. Thus you won't be doing the same things if you are moving something or if you are copying it.
-
The data contained in the drag object and the action you want to perform based on it are two unrelated things. So it will depend on your application