I have a QGraphicsScene with a QPushButton inside, and clearing this scene will crash my application. Is there a correct way to clear a scene with a QWidget ?
The following code crashes when clicking on the button:
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsProxyWidget>
#include <QPushButton>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QGraphicsScene *scene = new QGraphicsScene();
QGraphicsView *view = new QGraphicsView();
view->setScene(scene);
view->show();
QPushButton *button = new QPushButton("button");
QObject::connect(button, SIGNAL(clicked()), scene, SLOT(clear()));
QGraphicsProxyWidget *proxy = scene->addWidget(button);
return app.exec();
}