Display Image
-
@Tanuja said in Display Image:
Please help
please help us first!
How should anyone be able to help you by just saying "it doesn't work"?!? -
How r u displaying the image ? Using QLabel or drawing it as Pixmap ?Please share the appropriate code snippet. As @raven-worx said, it helps people to help you.
-
@raven-worx
QPixmap pix("image path");
ui->label->setpixmap(pix);
ui->label->show();This is the code which I have written.
Now can you please tell what is wrong in it. -
@Tanuja said in Display Image:
QPixmap pix("image path");
How does the path look like exactly?
What type of image?
Qt version?
Operating system?
... -
@raven-worx
This is the exact path:
D:/Tanuja/QtProjects/pic.jpgQt version is 5.6.2 and it's windows 32 but system
-
@Tanuja said in Display Image:
D:/Tanuja/QtProjects/pic.jpg
i have to ask: you are sure that this file exists?
If so, how did you run your application? out of QtCreator or already deployed (with Qt dlls)? In case of deployed make sure that the imageformat plugins are also deployed.
-
@raven-worx
Yes this image is present at the specified location.
And I am running my code from qt creator only.Also, I have tried adding this image through form by giving image through the pixmap property of qlabel. But still on running the image is not displayed.
-
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.