I am creating a graphics scene in Qt widgets application. The application runs successfully but no graphics scene is displayed.
The code that I am using to create scene is:
cadviewer::cadviewer(QGraphicsScene *parent) :
QGraphicsScene(parent)
{
QGraphicsScene scene;
scene.addLine(10,10,20,20);
QGraphicsView view(&scene);
view.show();
qDebug() << "cadviewer";
}
The call to the above class is made in another class. The code for the same is:
graphicsarea::graphicsarea(QWidget *parent) :
QWidget(parent),
ui(new Ui::graphicsarea)
{
ui->setupUi(this);
cadviewer viewer;
qDebug() << "graphicsarea";
}
The qDebug used in the two classes is working.
I am unable to figure out what's missing. Do help me out how to display the graphics scene in the main window?