Drag and Drop?
-
I've tried testing the DropSite example included with Qt 5.3.1, and that works without any issues.
There are very few differences between the two projects, but I'm using Visual Studio 2012 (Qt 1.2.3 integration). I guess it's possible I'm missing a module or a project setting somewhere?
-
Hi,
Can you check if "this":https://qt-project.org/forums/viewthread/28509 post would work for you ?
-
Hi p3c0,
I checked out the post you linked to, and unfortunately it didn't seem to make any difference... I tried overriding
@
bool dropMimeData(...)...
setDragDropMode( QAbstractItemView::InternalMove );
@But I'm not getting any callbacks when I drag a file over the application windows (I still get the black circle with a strike-through icon), this includes dragEnterEvent, dragMoveEvent & dragLeaveEvent.
I don't think it's a problem with the widget implementation though - pretty sure it's coming from a higher level in Qt because I tried deriving my base class from QLabel, with the same result.
-
Try setting
@
setDragDropMode(QAbstractItemView::DragDrop);
@ -
No luck - I've tried most of the drag drop modes without any favorable results.
It must be coming from a higher level that the QWidget that I'm deriving from though; if I derive the base class from QLabel instead of QTreeWidget/QTreeView I get the exact same behaviour.
-
Hi,
Did you look at the "item view dedicated":http://qt-project.org/doc/qt-5/model-view-programming.html#using-drag-and-drop-with-item-views drag and drop documentation ?
Hope it helps
-
Hi SGaist,
I had a look at the item view link you posted, but no luck unfortunately... setting the viewport & drop indicators doesn't make any difference to the application.
There has to be something broken at a higher level in my application, since deriving from QLabel (like in the Qt DropBox example) doesn't work either.
-
Just to be sure, did you try to run one of the example to ensure it's working correctly ?
-
I did, yeah (DropZone) - but from the Qt Creator application. I'm going to try and create the UI programmatically to see if that makes any difference.
-
I've been messing around with this, trying to get drag and drop working - and the problem seems to be coming from the way the project is set up by the VS2012 integration.
If I create a completely empty project, link to the Qt libs and derive my main window class from either QWidget or QMainWindow everything works without any issues (assuming I call setAcceptsDrops(true) ). This does present a problem though, since I don't get the auto generated metadata if I use the Q_OBJECT macro in my class definitions.
If I use the Qt5 Project templates when I create the project, I get all of the metatdata generation for free... but drag/drop just doesn't work (using the same source code from the empty project). Whenever I drag a file from windows explorer over the application I get the invalid operation icon (shown in the first post in the thread).
Any ideas?