Qt-interest Archive, July 2007
QGraphicsItemGroup
Message 1 in thread
Hi. I'm having some problems with QGraphicsItemGroup (on Mac, Qt 4.3)
and am hoping for some help. In the simplest-case example below, I
create two QGraphicsRectItems and put them in a group. When I try to
click and drag the group, it works if I click BETWEEN the items, but
not ON them.
Am I missing some flag that will allow me to click anywhere on the
group? (In my real app, which is considerably more complicated, when I
start to drag an item then entire group goes zooming off the screen in
the -X, -Y direction.)
Thanks!
------
QApplication app(argc, argv);
QGraphicsScene scene(0, 0, 400, 300);
QGraphicsView view(&scene);
view.show();
QGraphicsRectItem* rect1 = scene.addRect(QRectF(10,10,30,30));
QGraphicsRectItem* rect2 = scene.addRect(QRectF(50,10,30,30));
rect1->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
rect2->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
rect1->setSelected(true);
rect2->setSelected(true);
QGraphicsItemGroup *group = scene.createItemGroup(scene.selectedItems());
group->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
return app.exec();
--
[ signature omitted ]