Reputation: 10868
I have a normal widget application which should show a finite automata in a graphic view widget. I add a QGgraphicsView to the main window, which has an instance of QGraphicsScene:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
scene(new QGraphicsScene(this))
{
setupUi(this);
scene->addText("Hello");
ui->graphicsView->setScene(scene); // bumb!
}
Program crashes by a segmentation fault when it tries to set scene for graphicsView.
Upvotes: 1
Views: 713
Reputation: 29896
You should choose between inheriting from the ui class and having a ui member.
Then the code should be either:
ui->setupUi(this);
...
ui->graphicsView->setScene(scene);
or:
setupUi(this);
...
graphicsView->setScene(scene);
Upvotes: 3