PDA

View Full Version : QGraphicsItem::ItemIsMovable in QGraphicsScene, add actions on drop



gal
5th August 2015, 15:45
Hi!
I have a QGraphicsScene set in a QGraphicsView
In the scene I put a pixmap which is movable.
If the user drags and drops the pixmap inside the QGraphicsScene, on the drop action, I want to do some things in my program.



_scene = std::make_shared<QGraphicsScene>();
ui->graphicsView->setScene(_scene.get());
QGraphicsPixmapItem* pixmap = _scene->addPixmap(QPixmap::fromImage(some_QImage);
pixmap->setFlag(QGraphicsItem::ItemIsMovable);


Does anyone know how to do such a thing? Is it possible with reimplementation of dragEnterEvent, dragMoveEvent, dropEvent? I tried it in the GraphicsScene and the GraphicsView but it didn't reach my reimplemented event methods.

Thank you
Gal

anda_skoa
5th August 2015, 21:12
If you move the pixmap item, then there is no drag&drop involved at all.

Cheers,
_

gal
6th August 2015, 15:37
Thanks, I got confused, I needed to use mouseReleaseEvent