Unsolved display image in qt
-
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
-
This post is deleted! -
This post is deleted! -
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. -
@Rameshguru
Is your image a QPixmap? -
@Rameshguru
Show the code where you create the image. -
http://www.qtcentre.org/threads/45104-Image-not-appearing-in-Qlabel-after-compiling
see thiz and clear your doubts
-
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
-
@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.