[Qt-interest] mouse/dragdrop events in Qgraphics
Mahendra G.R
mahendra at mahendragr.com
Fri Nov 5 09:13:02 CET 2010
Hi all,
i'm trying to implent dragdrop functionality in Qgraphics, but for some
reason when i drag, the items(polygons in my case) are not moving. i'm
attaching the source code, can anyone please shed some light.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view;
QPixmap pixmap("cross_out.PNG");
QPolygonF polygon1,polygon2;
QGraphicsPolygonItem item1,item2;
scene.addPixmap(pixmap);
scene.blockSignals(true);
polygon1 << QPointF(50.4, 20.5) << QPointF(100.2,
40.2)<<QPointF(100.2, 100.2)<<QPointF(50.4,100.5);
polygon2 << QPointF(200.4, 200.5) << QPointF(200.2,
90.2)<<QPointF(220.2, 100.2);
item1.setPen(QPen(Qt::red));
item1.setPolygon(polygon1);
item1.setAcceptDrops(true);
item1.setFlag(QGraphicsPolygonItem::ItemIsMovable);
item2.setPen(QPen(Qt::blue));
item2.setPolygon(polygon2);
item2.setAcceptDrops(true);
item2.setFlag(QGraphicsPolygonItem::ItemIsMovable);
scene.addItem(&item1);
scene.addItem(&item2);
view.setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
view.setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
view.setScene(&scene);
view.resize(300,300);
view.show();
return a.exec();
}
which method(s) should i override, mouserelese/move/press events or the
drag/drop events in order to move the polygons and get the current vertices
of the polygon after it is moved.
Thanks,
Best regards
--
http://www.mahendragr.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101105/9803c74d/attachment.html
More information about the Qt-interest-old
mailing list