Drag and drop between QTableView and QGraphicsView (from model to model)
-
What I have done till now:
drag side:
I have a subclassed QTableView. I reimplemented the mouseMoveEvent function. Here I assembled the mimedata and started the drag.
This event is running good when I drag a row from the table.drop side:
This is a subclassed QGraphicsView, here I have some pixmap on the scene (and on the view). I reimplemented the dragEnterEvent what is running good.But:
I reimplemented the dropEvent too, but this event doesn't run at all...@
void DisplayLayout::dropEvent(QDropEvent* event)
{
qDebug() << "dropEvent" ;
}
@Why?
(And what is the different between event->acceptProposedAction(); and event->setAccepted(true); ?)
-
Another "helpful wiki entry":https://qt-project.org/doc/qt-4.8/model-view-programming.html#using-drag-and-drop-with-item-views on the subject.
Make sure you have enabled drag & drop in both views, and that the mime data is accepted.
-
Thx the link, I've read this article.
My mimedata seems to be good.
I've set in the views the setDragEnabled(true) and setAcceptDrops(true);What I'd like to: select a row in the table (get the ID), and I pass this ID into the graphicsview, and added a pixmap with this ID.
But I have no succes :(