#include int main(int argc, char **argv) { QApplication app(argc, argv); QGraphicsScene scene(0.0, 0.0, 500.0, 500.0); QGraphicsView view(&scene); // Create a parent and child QGraphicsProxyWidget QGraphicsProxyWidget* parent(new QGraphicsProxyWidget); QGraphicsProxyWidget* child(new QGraphicsProxyWidget); child->setParentItem(parent); // Create two different labels that will be assigned to the parent. QLabel* label0(new QLabel); label0->setText("First"); QLabel* label1(new QLabel); label1->setText("Second"); // Set the first label as the proxied widget. parent->setWidget(label0); // If we attempt to change the proxied widget we get a crash. parent->setWidget(label1); scene.addItem(parent); view.show(); return app.exec(); }