Unsolved Can't send image to QLabel in Windows environment (it works without problems in Linux)
-
Hi!
I can't output the image to QLabel in a Windows environment.
I tried it in two ways. The image size is 144 x 88 pixels (~ 3 KB).- using QImage:
const QString tmb_file = "C:\\Users\\User\\thumbnail.jpg"; const QImage img = QImage(tmb_file, "JPG"); const QPixmap pixmap = QPixmap::fromImage(img); ui->labelThumb->setPixmap(pixmap);
- directly via QPixmap:
const QString tmb_file = "C:\\Users\\User\\thumbnail.jpg"; const QPixmap pixmap = QPixmap(tmb_file); ui->labelThumb->setPixmap(pixmap);
-
@Helge1980 said in Can't send image to QLabel in Windows environment (it works without problems in Linux):
I can't
"I cant" is not a proper description of an issue :)
Try
/
instead of\\
. -
Replacing \ \ with / didn't help
-
-
@Helge1980
As @Christian-Ehrlicher has said. Also,QPixmap(tmb_file)
andQPixmap::fromImage(img)
will return a pixmap whereQPixmap::isNull() == true
, and similarly forQImage(tmb_file, "JPG")
. You should check for this, both for debugging/because you have a problem and anyway at runtime since you're reading from a file. -
Yes, the file exists and is readable
-
Did you relocate Qt or similar? Please check if you jpg image plugin is available and check if jpg can be loaded with e.g. QImageReader::supportedFormats()
-
No, I didn't move the Qt libraries, everything was installed automatically.
Indeed, for some reason there is no support for the JPG format:
qDebug() << QImageReader::supportedImageFormats();
("bmp", "pbm", "pgm", "png", "ppm", "xbm", "xpm")
-
The jpeg plugin must be in <QTDIR>/plugins/imageformats
-
Stupid question:
Is thelabelThumb
QLabel
visible and enabled in your GUI?@Helge1980 said in Can't send image to QLabel in Windows environment (it works without problems in Linux):
("bmp", "pbm", "pgm", "png", "ppm", "xbm", "xpm")
Edit: Ah ok, so no JPG plugin
-
This post is deleted! -
I solved the problem by replacing the jpg format with png