No show of QPixmap
-
@Stan-Huang said in No show of QPixmap:
I'm sure it's existent and readable.
Although you are 'sure' you should check it with the function I pointed you to ...
@Christian-Ehrlicher setPixmap(pixmap_RoadFault) is void, so no return.
-
@Stan-Huang said in No show of QPixmap:
setPixmap(pixmap_RoadFault) is void, so no return.
Pleae read my link: http://doc.qt.io/qt-5/qpixmap.html#isNull - no setPixmap() but QPixmap::isNull() ...
-
@Stan-Huang said in No show of QPixmap:
The return of "file /exe/bv/image/sdkpic.jpg" is:
root@mitacimx6:/opt/BVDemo/smartbox# file /exe/bv/image/sdkpic.jpg
/exe/bv/image/sdkpic.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1108x1478, frames 3OK, it looks like the file is valid.
Next, check if Qt can understand the file format. What do you get when you call
qDebug() << QImageReader::supportedImageFormats()
? (remember #include <QDebug> and #include <QImageReader>)@JKSH The return is:
("bmp", "cur", "gif", "ico", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "xbm", "xpm") -
@Stan-Huang said in No show of QPixmap:
setPixmap(pixmap_RoadFault) is void, so no return.
Pleae read my link: http://doc.qt.io/qt-5/qpixmap.html#isNull - no setPixmap() but QPixmap::isNull() ...
-
What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?
-
@Stan-Huang
It's not quite clear from the code you posted, but are you sure thatpalette_RoadFault
is not set to something invalid somewhere else in your code, and thatpalette_RoadFault
persists outside the scope of your function?QBrush expects a const reference to a QPixmap, I don't think it will take ownership or make a copy of the QPixmap for drawing.
-
What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?
@SGaist I did it but still doesn't work:
ui->label->setGeometry(20,20,60,20);
ui->label->setPixmap(pixmap_RoadFault);
ui->label->show(); -
What if you set the pixmap directly on the QLabel rather than using a brush in the palette ?
@SGaist I did but still doesn't work:
ui->label->setGeometry(20,20,60,20); ui->label->setPixmap(pixmap_RoadFault); ui->label->show();
-
Don't set the geometry since you have a designer based UI, that will let QLabel in its original place to show the pixmap.
If it's still not working, then test again with another image. And if possible, share that file with us so that we can test it on our ends.
-
That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.
-
That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.
@Stan-Huang said in No show of QPixmap:
That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.
I'm glad to hear that you've got it working now.
Like I said 10 days ago, it's best to use simple examples. I even wrote a full program for you that works, but you didn't use it.
-
@Stan-Huang said in No show of QPixmap:
That's my mistake. A clear statement was executed right after ->show() was executed. That's, show() did its good job, but the shown picture was cleaned immediately. I apologize for my mistake.
I'm glad to hear that you've got it working now.
Like I said 10 days ago, it's best to use simple examples. I even wrote a full program for you that works, but you didn't use it.
@JKSH Yes. I didn't do it 10 days ago due to 9-day lunar new year vacation. Thanks very much.