PDA

View Full Version : Display a jpg file in a widget.



sonu
26th October 2007, 11:55
Dear Everyone,
How can we display a jpg file in a widget.
I m using following code but there is no output .....:confused:
QLabel *imageLabel;
imageLabel = new QLabel(this,0);
imageLabel->setGeometry ( locx,locy,w,h );
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
imageLabel->setScaledContents(true);
QImage image(mediaPath[currentIndex]);
if (!image.isNull())
{
qDebug()<<"Image"<<mediaPath[currentIndex];
}
imageLabel->setPixmap(QPixmap::fromImage(image));

Please if you have any idea about it give reply.
Thanks:

jacek
26th October 2007, 12:11
Do you have the QJPEG plugin? What does QImageReader::supportedImageFormats() return?

P.S. Please, don't double-post.

sonu
26th October 2007, 15:38
Hello Everyone,
I m displaying a .jpg file in a widget through QLabel and QScrollerArea Class .
But it does not display the .jpg files:eek:
My coding is as following ..........

QLabel *imageLabel;
imageLabel = new QLabel;
imageLabel->setBackgroundRole(QPalette::Base);
imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
imageLabel->setScaledContents(TRUE);

QImage image(mediaPath[currentIndex]);
imageLabel->setPixmap(QPixmap::fromImage(image));
imageLabel->resize(imageLabel->pixmap()->size());
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(imageLabel);
scrollArea->setWidgetResizable(TRUE);

If anyone has any idea please reply it.
Thanks in advance......................:)

wysota
26th October 2007, 15:41
Does it display PNG files? If so, look here: http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_missing_ima ges

jacek
26th October 2007, 16:17
Please, don't start more than one thread on the same problem.