QLibrary Class Reference |
Constant | Value | Description |
---|---|---|
QLibrary.ResolveAllSymbolsHint | 0x01 | Causes all symbols in a library to be resolved when it is loaded, not simply when resolve() is called. |
QLibrary.ExportExternalSymbolsHint | 0x02 | Exports unresolved and external symbols in the library so that they can be resolved in other dynamically-loaded libraries loaded later. |
QLibrary.LoadArchiveMemberHint | 0x04 | Allows the file name of the library to specify a particular object file within an archive file. If this hint is given, the filename of the library consists of a path, which is a reference to an archive file, followed by a reference to the archive member. |
The LoadHints type is a typedef for QFlags<LoadHint>. It stores an OR combination of LoadHint values.
See also loadHints.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a library with the given parent.
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a library object with the given parent that will load the library specified by fileName.
We recommend omitting the file's suffix in fileName, since QLibrary will automatically look for the file with the appropriate suffix in accordance with the platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on Windows. (See fileName.)
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a library object with the given parent that will load the library specified by fileName and major version number verNum. Currently, the version number is ignored on Windows.
We recommend omitting the file's suffix in fileName, since QLibrary will automatically look for the file with the appropriate suffix in accordance with the platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on Windows. (See fileName.)
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a library object with the given parent that will load the library specified by fileName and full version number version. Currently, the version number is ignored on Windows.
We recommend omitting the file's suffix in fileName, since QLibrary will automatically look for the file with the appropriate suffix in accordance with the platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on Windows. (See fileName.)
Returns a text string with the description of the last error that occurred. Currently, errorString will only be set if load(), unload() or resolve() for some reason fails.
This function was introduced in Qt 4.2.
Returns true if fileName has a valid suffix for a loadable library; otherwise returns false.
Platform | Valid suffixes |
---|---|
Windows | .dll |
Unix/Linux | .so |
AIX | .a |
HP-UX | .sl, .so (HP-UXi) |
Mac OS X | .dylib, .bundle, .so |
Trailing versioning numbers on Unix are ignored.
Returns true if the library is loaded; otherwise returns false.
See also load().
Loads the library and returns true if the library was loaded successfully; otherwise returns false. Since resolve() always calls this function before resolving any symbols it is not necessary to call it explicitly. In some situations you might want the library loaded in advance, in which case you would use this function.
See also unload().
Returns the address of the exported symbol symbol. The library is loaded if necessary. The function returns 0 if the symbol could not be resolved or if the library could not be loaded.
Example:
typedef int (*AvgFunction)(int, int); AvgFunction avg = (AvgFunction) library->resolve("avg"); if (avg) return avg(5, 8); else return -1;
The symbol must be exported as a C function from the library. This means that the function must be wrapped in an extern "C" if the library is compiled with a C++ compiler. On Windows you must also explicitly export the function from the DLL using the __declspec(dllexport) compiler directive, for example:
extern "C" MY_EXPORT int avg(int a, int b) { return (a + b) / 2; }
with MY_EXPORT defined as
#ifdef Q_WS_WIN #define MY_EXPORT __declspec(dllexport) #else #define MY_EXPORT #endif
This is an overloaded member function, provided for convenience.
Loads the library fileName and returns the address of the exported symbol symbol. Note that fileName should not include the platform-specific file suffix; (see fileName). The library remains loaded until the application exits.
The function returns 0 if the symbol could not be resolved or if the library could not be loaded.
See also resolve().
This is an overloaded member function, provided for convenience.
Loads the library fileName with major version number verNum and returns the address of the exported symbol symbol. Note that fileName should not include the platform-specific file suffix; (see fileName). The library remains loaded until the application exits. verNum is ignored on Windows.
The function returns 0 if the symbol could not be resolved or if the library could not be loaded.
See also resolve().
This is an overloaded member function, provided for convenience.
Loads the library fileName with full version number version and returns the address of the exported symbol symbol. Note that fileName should not include the platform-specific file suffix; (see fileName). The library remains loaded until the application exits. version is ignored on Windows.
The function returns 0 if the symbol could not be resolved or if the library could not be loaded.
This function was introduced in Qt 4.4.
See also resolve().
Sets the fileName property and major version number to fileName and versionNumber respectively. The versionNumber is ignored on Windows.
See also setFileName().
This is an overloaded member function, provided for convenience.
Sets the fileName property and full version number to fileName and version respectively. The version parameter is ignored on Windows.
This function was introduced in Qt 4.4.
See also setFileName().
Unloads the library and returns true if the library could be unloaded; otherwise returns false.
This happens automatically on application termination, so you shouldn't normally need to call this function.
If other instances of QLibrary are using the same library, the call will fail, and unloading will only happen when every instance has called unload().
Note that on Mac OS X 10.3 (Panther), dynamic libraries cannot be unloaded.
See also resolve() and load().
PyQt 4.4.4 for Windows | Copyright © Riverbank Computing Ltd and Trolltech AS 2008 | Qt 4.4.2 |