Hi All
I have problem with function dropEvent(QGraphicsSceneDragDropEvent *event) when I wanna drop object type QGraphicsItem.
this is my part code
QPixmap dwuMasztowiec;
dwuMasztowiec = QPixmap("../Statki/images/dwu.png");
statek_1 = scene->addPixmap(dwuMasztowiec);
statek_1->setPos(277,405);
statek_1->setFlag(QGraphicsItem::ItemIsMovable);
I have several objects type statek (statek=ship). I wanna drag this ships somewhere in another place that I can drop and read position this ship.
I set flag (QGraphicsItem::ItemIsMovable) so I can drag elements but I haven't ideas how drop and read postion ship.
I used function (which is below) from example robot from Qt but doesn't work
void Plansza::dropEvent(QGraphicsSceneDragDropEvent *event)
{
if (event->mimeData()->hasImage()) {
dragOver = false;
pixmap = qVariantValue<QPixmap>(event->mimeData()->imageData());
update();
} else {
Plansza::dropEvent(event);
}
}
If I explained wrong my example , I will tell and show more details.
I please about support
Thanks
Bookmarks