display image in qt
-
wrote on 14 Jul 2018, 04:48 last edited by
how to display image in qt
i have use ui->label->setpixmap(image)but this code not working if other method is there please mention
-
wrote on 14 Jul 2018, 04:56 last edited byThis post is deleted!
-
wrote on 14 Jul 2018, 04:58 last edited byThis post is deleted!
-
wrote on 14 Jul 2018, 04:59 last edited by
Try this method bro,
The "Choose file" do NOT work with random paths.
it will become relative
"
label->setPixmap(QPixmap(QString::fromUtf8("../Pictures/taskbar3.png")));
"
But when run , the app is in the build folder and the pictures is NOT to be found with the relative path that is
from .pro location.So use resource file or load them your self with the correct path.
Just look in the setupUI function. you can see the paths it will use.
Then check from your build folder. its no longer correct. -
how to display image in qt
i have use ui->label->setpixmap(image)but this code not working if other method is there please mention
wrote on 14 Jul 2018, 05:00 last edited by@Rameshguru
Is your image a QPixmap? -
how to display image in qt
i have use ui->label->setpixmap(image)but this code not working if other method is there please mention
wrote on 14 Jul 2018, 05:03 last edited by@Rameshguru
Show the code where you create the image. -
wrote on 14 Jul 2018, 05:07 last edited by
http://www.qtcentre.org/threads/45104-Image-not-appearing-in-Qlabel-after-compiling
see thiz and clear your doubts
-
@Rameshguru
Show the code where you create the image.wrote on 14 Jul 2018, 05:11 last edited bychar* imgL = reinterpret_cast<char*>(pImageBuffer);
QImage imgLNew(reinterpret_cast<uchar*>(imgL), 400, 300, QImage::Format_RGB888);
imgLNew.save("new.tif");
QPixmap image1 = QPixmap::fromImage(imgLNew);this is my code sir
-
char* imgL = reinterpret_cast<char*>(pImageBuffer);
QImage imgLNew(reinterpret_cast<uchar*>(imgL), 400, 300, QImage::Format_RGB888);
imgLNew.save("new.tif");
QPixmap image1 = QPixmap::fromImage(imgLNew);this is my code sir
wrote on 14 Jul 2018, 07:16 last edited by kenchan@Rameshguru
Does the tif file you are saving look correct? How exactly does it not work?
Are you aware of this requirement for the constructor you are using "data must be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned"?, make sure your data conforms to that.
7/9