4

I have a QGraphicsScene for drawing, where I now want to "add" a QWidget to a QGraphicsItem (display on top of the item, which can of course be moved).

How could this be accomplished? Is there any QGraphicsItem, which may function as a Widget container?

1

1 Answer 1

5

You can use QGraphicsScene::addWidget which creates a new QGraphicsProxyWidget for widget, adds it to the scene, and returns a pointer to the proxy :

QGraphicsProxyWidget * item = myScene->addWidget(myWidget);
item->setParentItem(anOtherItem);
item->setPos(100,100);
item->setZValue(1);
1
  • 1
    What is that C style cast doing there?
    – thuga
    Commented Jun 18, 2014 at 10:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.