Hi!
I am trying to get the path top a QImage for my application.
I did as followd:
My problem is that I can not load any image.
What could be the problem? I will appreciate any help.
Many thanks in advance.
Hi!
I am trying to get the path top a QImage for my application.
I did as followd:
My problem is that I can not load any image.
What could be the problem? I will appreciate any help.
Many thanks in advance.
Where is the image name ? "myImage.png" , myImage.jpg ?? which one ?
Also what is the output of QCoreApplication::applicationDirPath() ?
Many thanks aamer4yu for your reply.
The image name should be myImage.png.
Have a look please. When I proceed as followed, I do not need to add ".png", and I can have the image loaded. But I do not want to go this way.
Qt Code:
image.load("C:/Users/Desktop/myImage");To copy to clipboard, switch view to plain text mode
Even by writing myImage.png, there is no change.
I have created a label on which th image should appear as followed:
Qt Code:
m_image->setPixmap(myImage);To copy to clipboard, switch view to plain text mode
Last edited by Stanfillirenfro; 15th January 2014 at 10:43.
Are you sure you know what QCoreApplication::applicationDirPath() returns ?
Thanks Lesiok!
Yes, QCoreApplication::applicationDirPath() returns the directory that contains the application executable.
Please put a qDebug() for QCoreApplication::applicationDirPath() value...
Thanks aamer4you for your reply.
I am instead trying to proceed like this:
Qt Code:
QDir dir; dir.setCurrent("C:/Users/File/Desktop/imageFile"); image.load(dir + "/myImage");To copy to clipboard, switch view to plain text mode
This does not function. Could you please have a lokk and give me an advice?
Many thanks in advance.
Added after 41 minutes:
I have solved the problem.
Many thanks for our help.
Last edited by Stanfillirenfro; 15th January 2014 at 13:09.
Can You show us what is FULL path to file myImage and what is result of QCoreApplication::applicationDirPath() ?
Hi Lesiok!
Of courses!
The initial idea was to load different images from a list, each image being represented by its name. So I had to get to the file in which the images are stored and to select an image. To be able to change the name of each image in the path, I thought I could use QCoreApplication::applicationDirPath(), but unfortunately I failed.
I finally proceed as followed:
Qt Code:
QStringList listImages; for(int i = 0; i<listImages.size(); i++) { if(listImages[i]) str.append(listImages[i]) image.load(str); m_image->setPixmap(image);To copy to clipboard, switch view to plain text mode
On this way I could solve my problem.
Thanks for your attention.
Bookmarks