⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qlibrary.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QLibrary 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQLibrary \- Wrapper for handling shared libraries.PP\fC#include <qlibrary.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQLibrary\fR ( const QString & filename )".br.ti -1c.BI "virtual \fB~QLibrary\fR ()".br.ti -1c.BI "void * \fBresolve\fR ( const char * symb )".br.ti -1c.BI "bool \fBload\fR ()".br.ti -1c.BI "virtual bool \fBunload\fR ()".br.ti -1c.BI "bool \fBisLoaded\fR () const".br.ti -1c.BI "bool \fBautoUnload\fR () const".br.ti -1c.BI "void \fBsetAutoUnload\fR ( bool enabled )".br.ti -1c.BI "QString \fBlibrary\fR () const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "void * \fBresolve\fR ( const QString & filename, const char * symb )".br.in -1c.SH DESCRIPTIONThe QLibrary class provides a wrapper for handling shared libraries..PPAn instance of a QLibrary object can handle a single shared library and provide access to the functionality in the library in a platform independent way. If the library is a component server, QLibrary provides access to the exported component and can directly query this component for interfaces..PPQLibrary ensures that the shared library is loaded and stays in memory whilst it is in use. QLibrary can also unload the library on destruction and release unused resources..PPA typical use of QLibrary is to resolve an exported symbol in a shared object, and to e.g. call the function that this symbol represents. This is called "explicit linking" in contrast to" implicit linking", which is done by the link step in the build process when linking an executable against a library..PPThe following code snippet loads a library, resolves the symbol" mysymbol", and calls the function if everything succeeded. If something went wrong, e.g. the library file does not exist or the symbol is not defined, the function pointer will become a null pointer. Upon destruction of the QLibrary object the library will be unloaded, making all references to memory allocated in the library invalid..PP.nf.br  typedef void (*MyPrototype)();.br  MyPrototype myFunction;.br.br  QLibrary myLib( "mylib" );.br  myFunction = (MyProtoype) myLib.resolve( "mysymbol" );.br  if ( myFunction ) {.br      myFunction();.br  }.br.fi.SH MEMBER FUNCTION DOCUMENTATION.SH "QLibrary::QLibrary ( const QString & filename )"Creates a QLibrary object for the shared library \fIfilename\fR. The library will be unloaded in the destructor..PPNote that \fIfilename\fR does not need to include the (platform specific) file extension, so calling.PP.nf.br  QLibrary lib( "mylib" );.br.fiis equivalent to calling.PP.nf.br  QLibrary lib( "mylib.dll" );.br.fion Windows. Specifying the extension is not recommended, since doing so introduces a platform dependency..PPIf \fIfilename\fR does not include a path, the library loader will look for the file in the platform specific search paths..PPSee also load(), unload() and setAutoUnload()..SH "QLibrary::~QLibrary ()\fC [virtual]\fR"Deletes the QLibrary object..PPThe library will be unloaded if autoUnload() is TRUE (the default), otherwise it stays in memory until the application is exited..PPSee also unload() and setAutoUnload()..SH "bool QLibrary::autoUnload () const"Returns TRUE if the library will be automatically unloaded when this wrapper object is destructed; otherwise returns FALSE. The default is TRUE..PPSee also setAutoUnload()..SH "bool QLibrary::isLoaded () const"Returns TRUE if the library is loaded; otherwise returns FALSE..PPSee also unload()..SH "QString QLibrary::library () const"Returns the filename of the shared library this QLibrary object handles, including the platform specific file extension..PPFor example:.PP.nf.br  QLibrary lib( "mylib" );.br  QString str = lib.library();.br.fi.PPwill set \fIstr\fR to "mylib.dll" on Windows, and "libmylib.so" on Linux..SH "bool QLibrary::load ()"Loads the library. Since resolve() always calls this function before resolving any symbols it is not necessary to call this function explicitly. In some situations you might want the library loaded in advance, in which case you would call this function..SH "void * QLibrary::resolve ( const char * symb )"Returns the address of the exported symbol \fIsymb\fR. The library is loaded if necessary. The function returns a null pointer if the symbol could not be resolved or the library could not be loaded..PP.nf.br  typedef int (*avgProc)( int, int );.br.br  avgProc avg = (avgProc) library->resolve( "avg" );.br  if ( avg ).br      return avg( 5, 8 );.br  else.br      return -1;.br.fi.SH "void * QLibrary::resolve ( const QString & filename, const char * symb )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPLoads the library \fIfilename\fR and returns the address of the exported symbol \fIsymb\fR. Note that like the constructor, \fIfilename\fR does not need to include the (platform specific) file extension. The library remains loaded until the process exits..PPThe function returns a null pointer if the symbol could not be resolved or the library could not be loaded..SH "void QLibrary::setAutoUnload ( bool enabled )"If \fIenabled\fR is TRUE (the default), the wrapper object is set to automatically unload the library upon destruction. If \fIenabled\fR is FALSE, the wrapper object is not unloaded unless you explicitly call unload()..PPSee also autoUnload()..SH "bool QLibrary::unload ()\fC [virtual]\fR"Unloads the library and returns TRUE if the library could be unloaded; otherwise returns FALSE..PPThis function is called by the destructor if autoUnload() is enabled..PPSee also resolve()..SH "SEE ALSO".BR http://doc.trolltech.com/qlibrary.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qlibrary.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -