![]() |
Home · All Classes · Main Classes · Grouped Classes · Modules · Functions | ![]() |
The QResource class provides an interface for reading directly from resources. More...
#include <QResource>
Note: All the functions in this class are reentrant.
The QResource class provides an interface for reading directly from resources.
QResource is an object that represents a set of data (and possibly children) relating to a single resource entity. QResource gives direct access to the bytes in their raw format. In this way direct access allows reading data without buffer copying or indirection. Indirection is often useful when interacting with the resource entity as if it is a file, this can be achieved with QFile. The data and children behind a QResource are normally compiled into an application/library, but it is also possible to load a resource at runtime. When loaded at run time the resource file will be loaded as one big set of data and then given out in pieces via references into the resource tree.
A QResource can either be loaded with an absolute path (either treated as a file system rooted with /, or in resource notation rooted with :). A relative resource can also be opened which will be found through the searchPaths().
A QResource that is representing a file will have data backing it, this data can possibly be compressed, in which case qUncompress() must be used to access the real data; this happens implicitly when accessed through a QFile. A QResource that is representing a directory will have only children and no data.
See also The Qt Resource System, QFile, QDir, and QFileInfo.
Constructs a QResource pointing to file.
See also QFileInfo, searchPaths(), and setFile().
Releases the resources of the QResource object.
Adds path to the search paths searched in to find resources that are not specified with an absolute path. The default search path is to search only in the root (:/). The last path added will be consulted first upon next QResource creation.
See also QResource::QResource and addSearchPath().
Returns the real path that this QResource represents, if the resource was found via the searchPaths() it will be indicated in the path.
See also filePath().
Returns direct access to a read only segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory 0 is returned.
See also size(), isCompressed(), and isFile().
Returns the full path to the file that this QResource represents as it was passed.
See also setFilePath() and canonicalFilePath().
Returns true if the resource represents a file and the data backing it is in a compressed format, false otherwise.
See also data() and isFile().
Returns true if the resource really exists in the resource heirarchy, false otherwise.
A resource can be left out of your binary and then loaded at runtime, this can often be useful to load a large set of icons into your application that may change based on a setting or that can be edited by a user and later recreated. The resource is immediately loaded into memory (either by reading as a single file, or being memory mapped), this can prove to be a significant gain as only a single file will be loaded and then pieces of the data will be given out via the path requested in QResource::setFile(). Returns true upon successful opening of rccFileName, false upon failure.
See also unregisterResource().
Returns the current search path list. This list is consulted when creating a relative resource.
See also QResource::QResource and addSearchPath().
Sets a QResource to point to file. file can either be absolute, in which case it is opened directly, if relative then the file will be tried to be found in searchPaths().
See also filePath() and canonicalFilePath().
Returns the size of the data backing the resource.
See also data() and isFile().
Removes a reference to rccFilename, returns true if the resource could be unloaded, false otherwise. If there are QResources that currently reference resources inside of the resource they will continue to be valid but the resource file itself will be removed from the resource roots and thus no further QResource can be created pointing into this resource data. The resource itself will be unmapped from memory when the last QResource points into it.
See also registerResource().
Copyright © 2006 Trolltech | Trademarks | Qt 4.2.0-snapshot-20060701 |