PythonQt.QtCore.QResource
QResource
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
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 a / character, or in resource notation rooted with a : character. A
relative resource can also be opened which will be found in the list of paths returned
by QDir::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.
Dynamic Resource Loading
A resource can be left out of an application's binary and loaded when it is needed at run-time by using the registerResource() function. The resource file passed into registerResource() must be a binary resource as created by rcc. Further information about binary resources can be found in The Qt Resource System documentation.
This can often be useful when loading a large set of application icons 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 as a result of a single file read operation, or as a memory mapped file.
This approach can prove to be a significant performance gain as only a single file will be loaded, and pieces of data will be given out via the path requested in setFileName().
The unregisterResource() function removes a reference to a particular file. If there are QResource objects that currently reference resources related to the unregistered file, 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 that points to it is destroyed.
Source: https://doc.qt.io/archives/qt-5.15/qresource.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
absoluteFilePath |
function | (self) -> str |
X.absoluteFilePath() -> str |
addSearchPath |
function | (self, path: str) -> None |
|
children |
function | (self) -> tuple |
X.children() -> tuple |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
data |
function | (self) -> str |
X.data() -> int |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
fileName |
function | (self) -> str |
X.fileName() -> str |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
isCompressed |
function | (self) -> bool |
X.isCompressed() -> bool |
isDir |
function | (self) -> bool |
X.isDir() -> bool |
isFile |
function | (self) -> bool |
X.isFile() -> bool |
isValid |
function | (self) -> bool |
X.isValid() -> bool |
locale |
function | (self) -> Any |
X.locale() -> PythonQt.QtCore.QLocale |
registerResource |
function | (self, rccFilename: str, resourceRoot: str) -> bool |
X.registerResource(rccFilename, resourceRoot) -> bool |
searchPaths |
function | (self) -> tuple |
X.searchPaths() -> tuple |
setFileName |
function | (self, file: str) -> None |
Sets a [QResource](https://doc.qt.io/archives/qt-5.15/qresource.html) to point to file. file can either be absolute, in which case it is opened directly, if relative then the file will be tried… |
setLocale |
function | (self, locale: Any) -> None |
Sets a [QResource](https://doc.qt.io/archives/qt-5.15/qresource.html) to only load the localization of resource to for locale. |
size |
function | (self) -> int |
X.size() -> int |
unregisterResource |
function | (self, rccFilename: str, resourceRoot: str) -> bool |
X.unregisterResource(rccFilename, resourceRoot) -> bool |