I have created a Qt Widgets Application using Qt Creator(Windows 7, MinGW).
I have added a GraphicsView (named as graphicsView
) and a push button (named as pbClick
).
The on_pbClick_clicked()
function is given below:
void MainWindow::on_pbClick_clicked()
{
QGraphicsScene scene;
//adding some text to the scene
scene.addText("Hello, world!", QFont("Times", 20, QFont::Bold));
ui->graphicsView->setScene(&scene);
ui->graphicsView->show();
}
When I click the pbClick
button, nothing happens within the graphicsView
.
How can I make the "Hello, world!" text be shown inside the graphicsView
.