tags:

views:

42

answers:

3

Lets say I have a resource at ':images/pic.gif'

Can i make a QPIcture from this resource or does it have to be loaded from file?

A: 

you have to use Qicon or Qpixmap to load the images from resource. QPIcture is used to save the picture.

Shadow
A: 

I think your question is like after adding images/pic.gif into the resource file whether it has to be accessed from the resource file or the directly the location of images/pic.gif.

Now my answer for the question is, even if you have added the images into resource file and accessing it, it will indirectly access the physical file itself. To illustrate this, after adding the images/pic.gif into the resource file, try removing the images/pic.gif from the location and access within your application. You will not able to get the image. So, even if you add it into the resource file it is similar to access the physical file present in its original location. Check out the Qt Resources page.

But it is a good practice and logical to organize your required files into a resource file so that all the required files are present in the same location.

Using QPicture you can load it into your application through

bool QPicture::load ( const QString & fileName, const char * format = 0 )
liaK
+2  A: 

QPicture is for recording QPainter commands, not for image data. If you want to load an image, use QPixmap or QImage. You can use their load() methods. To access an image file bundled as a resource, use ":/" to access the resource: ":/someFile.png". The exact paths and filenames are specified in the qrc files.

Frank