0
votes

I m having some images that I load from some paths C:/....png to display them in a user interface, and a file that I would like to insert whithout specifying everytime its path

I tried to include images in my project and access them directly without specifying their addresses, especially that I would work on many machines and I don't want to change the path everytime, and create folders and images again. It didn't work!

I use a QPixmap to load images and have access to the image like what is follow:

QPixmap image("C:/images/image.png");

Even if I include that file to the project (image.png), when doing

 QPixmap image("image.png"); 

the image is not found and pixmap is having nothing.

As for the file, it's a text file that I would like to insert to the project. "myFile.txt" which exits at:

C:/images/myFile.txt

Any ideas how to resolve that?

1
How you load them? How you deploy them? How you include them in the project? How you need to include them (embedded?) - Adriano Repetti
@Adriano See the edit above. - MelMed
Maybe just use relative path? If so, just copy this files to your working directory (check working directory in project settings). Also you can try use resource file to embed files to your execute. - user1837009

1 Answers

1
votes

I recommend using Qt's resource system. It allows you to store the images inside the executable, which is usually more convenient than having a lots of files alongside the executable.