Radio button and show an image
-
Hi
Trying to show a different image when a radio button is toggled.
I can change text in a lable and in a text box just fine, but to try to display an image won't work.
Have been seaching the forum and the web, but sofar nothing.The help file is sometime just too abstract for me to understand
@
void MainWindow::on_radioButton_toggled(bool checked)
{
ui->label_3->setText("selected 1"); //change text in a lable
ui->plainTextEdit->setPlainText("Selected 1"); //change text in a textboxui->graphicsView->show('/images/picture1.png'); //doesn't work
}@
Any hints ?
Thanks
-
From your user interface position a QLabel on your GUI form and change your function to this:
@ void MainWindow::on_radioButton_toggled(bool checked)
{
ui->label_3->setText("selected 1"); //change text in a lable
ui->plainTextEdit->setPlainText("Selected 1"); //change text in a textboxQPixmap mypix ("/images/picture1.png"); ui->label->setPixmap(mypix); }
@
You can check the doc to see what QPixmap is .Do everything you can to be as comfortable as you can with the doc.It is the best friend you can have with Qt:-)
-
[quote author="fiddler" date="1367805141"]Okay, I have no problem using a label, but what is the graphicsView box for then ?[/quote]"QGraphicsView":http://qt-project.org/doc/qt-5.0/qtwidgets/qgraphicsview.html is for showing a "QGraphicsScene":http://qt-project.org/doc/qt-5.0/qtwidgets/qgraphicsscene.html. They are part of the "Graphics View Framework":http://qt-project.org/doc/qt-5.0/qtwidgets/graphicsview.html which is designed to manage many (thousands of) 2D objects, with features like zooming, stretching, rotating, click-and-drag, etc.
If you want to show just one picture, use a QLabel :)