A little update; I made it work by overriding the dropMove() event and accepting it. When I did this it works, regardless of the dragDropMode. Not sure I understand how and why, but as long as it works, I guess I'm happy :-)
On Sat, Feb 6, 2016 at 1:35 PM, Thomas Sevaldrud <[email protected]> wrote: > Hi, > > In my application I have two QTreeWidgets, and I need to drag items from > one of them to the other. I am not copying or moving actual > QTreeWidgetItems, this operation simply indicates that I want to add an > item in the destination widget with values taken from the selected item in > the source widget. Both widgets have different custom type QTreeWidgetItems. > > I have implemented this from the MouseMoveEvent with a > QDrag::exec(Qt::CopyAction) and a simple text payload to test it out. In > the receiver end I have overridden dragEnterEvent and dropEvent like so: > > void DragDropWidget::dragEnterEvent(QDragEnterEvent *event) > > { > > qDebug() << "dragEnter"; > > if (event->mimeData()->hasFormat("text/plain")) > > event->acceptProposedAction(); > > } > > > void DragDropWidget::dropEvent(QDropEvent *event) > > { > > qDebug() << "drop: " << event->mimeData()->text(); > > event->acceptProposedAction(); > > > } > > > Now, this works, but only if I set the receiving QTreeWidget dragDropMode > to "InternalMove". I am worried that I'm doing this completely wrong, and > that it just works accidentally when I set this flag... Any input? > > Cheers, > Thomas > >
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
