init2null
7th November 2006, 07:14
The new Graphics View framework is great, but I'm having a problem with grouping items. In the example below, only the text item not in the group can be edited. How can I allow the user to edit text items in groups?
Thanks,
Wesley
#include <QtGui>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QGraphicsView win;
QGraphicsScene *scene = new QGraphicsScene(&win);
QGraphicsTextItem *textItem = new QGraphicsTextItem("In a Group", NULL, scene);
textItem->setPos(50, 50);
textItem->setTextInteractionFlags(Qt::TextEditable|Qt::TextS electableByMouse);
QGraphicsItemGroup *group = new QGraphicsItemGroup(NULL, scene);
group->addToGroup(textItem);
QGraphicsTextItem *textItem2 = new QGraphicsTextItem("Not in a Group", NULL, scene);
textItem2->setPos(50, 10);
textItem2->setTextInteractionFlags(Qt::TextEditable|Qt::TextS electableByMouse);
win.setScene(scene);
win.show();
app.exec();
return 0;
}
Thanks,
Wesley
#include <QtGui>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QGraphicsView win;
QGraphicsScene *scene = new QGraphicsScene(&win);
QGraphicsTextItem *textItem = new QGraphicsTextItem("In a Group", NULL, scene);
textItem->setPos(50, 50);
textItem->setTextInteractionFlags(Qt::TextEditable|Qt::TextS electableByMouse);
QGraphicsItemGroup *group = new QGraphicsItemGroup(NULL, scene);
group->addToGroup(textItem);
QGraphicsTextItem *textItem2 = new QGraphicsTextItem("Not in a Group", NULL, scene);
textItem2->setPos(50, 10);
textItem2->setTextInteractionFlags(Qt::TextEditable|Qt::TextS electableByMouse);
win.setScene(scene);
win.show();
app.exec();
return 0;
}