How to display a picture
-
@Payx
it should work with *.jpg.- but i can't find how to convert a QStringList to a Qimage or Qpixmap
Oh just use
fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), "/", tr("Image Files (*.png *.jpg *.bmp)"));It only returns the 1 filename. ( NOTE THE MISSING s)
ui->mylabel->setPixmap( new QPixmap(fileName ));
-
If u are using QImage
m_imageLabel = new QLabel; QImage imagePixmap; imagePixmap.load(":/new/prefix1/Images/imageName.extension"); m_imageLabel->setPixmap(QPixmap::fromImage(imagePixmap));
Or
Only QPixmap
m_imageLabel = new QLabel; QPixmap imagePixmap; imagePixmap.load(":/new/prefix1/Images/imageName.extension"); m_imageLabel->setPixmap(imagePixmap);
imageName.extension can be image.png, image.jpeg.
-
@Pradeep-Kumar said in How to display a picture:
If u are using QImage
m_imageLabel = new QLabel; QImage imagePixmap; imagePixmap.load(":/new/prefix1/Images/imageName.extension"); m_imageLabel->setPixmap(QPixmap::fromImage(imagePixmap));
Or
Only QPixmap
m_imageLabel = new QLabel; QPixmap imagePixmap; imagePixmap.load(":/new/prefix1/Images/imageName.extension"); m_imageLabel->setPixmap(imagePixmap);
imageName.extension can be image.png, image.jpeg.
U didnt read the thread i think :-).
But thx@mrjj Lol no problem :-)
Thanks it works i will create an other thread for an other question after -
Thread says how to display a picture
@Payx
Is this the thing?.
correct me if i was wrong. -
@Pradeep-Kumar said in How to display a picture:
Thread says how to display a picture
@Payx
Is this the thing?.
correct me if i was wrong.wow u just answer the question after 5 guys answer me.
-
Hmmmmmmmmmm was toooooooooooo late.:)))
-
Thanks it works i will create an other thread for an other question after
If it is working can u mark thread has solved, so it will be useful in future.
Cheers.:)))))))Thanks,
-
u have already marked as solved for this thread.
-
Anyways in the right bottom of the topic u will see topic button and u see mark as solved under the topic button, click on it.
:)
Thanks.
-
The link address has expired
Please pay attention to select the example corresponding to your current qt version in the upper right corner
https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/widgets/imageviewer?h=5.15