Include images and file in the project

I have some images that I load from some C: / .... png paths to display them in the user interface, and a file that I would like to insert without specifying each path of its path

I tried to include images in my project and access them directly without specifying their addresses, especially that I will work on many machines, and I do not want to change the path every time and again create folders and images. It didnโ€™t work!

I use QPixmap to upload images and access the image, like what follows:

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

Even if I include this file in the project (image.png), when executed

  QPixmap image("image.png"); 

image not found, but pixmap has nothing.

As for the file, this is a text file that I would like to insert into the project. "myFile.txt", which comes out:

 C:/images/myFile.txt 

Any ideas how to solve this?

0
c ++ qt image visual-studio-2010 project
Jul 23 '13 at 9:36 on
source share
1 answer

I recommend using the Qt resource system . It allows you to store images inside an executable file, which is usually more convenient than having a large number of files with the executable file.

+2
Jul 23 '13 at 9:57 on
source share



All Articles