I know this thread is old but I found it through Google and just wanted to help people that stumble upon this thread.
So if you want to Drag a QGraphicsItem you need to signal Qt when you want a Drag-Event to be started.
So what guilugi forgot was to Generate a QDrag Object to let Qt know that a Drag event started.
This is the example from the dragdroprobot-example:
{
if (QLineF(event
->screenPos
(), event
->buttonDownScreenPos
(Qt
::LeftButton)) return;
}
drag->setMimeData(mime);
/* . . . */
drag->exec();
/* . . . */
}
void ColorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
.length() < QApplication::startDragDistance()) {
return;
}
QDrag *drag = new QDrag(event->widget());
QMimeData *mime = new QMimeData;
drag->setMimeData(mime);
/* . . . */
drag->exec();
/* . . . */
}
To copy to clipboard, switch view to plain text mode
Bookmarks