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

📄 qlibrary.html

📁 QT 下载资料仅供参考
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/tools/qlibrary.cpp:74 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QLibrary Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLibrary Class Reference</h1><p>The QLibrary class provides a wrapper for handling shared libraries.<a href="#details">More...</a><p><tt>#include &lt;<a href="qlibrary-h.html">qlibrary.h</a>&gt;</tt><p><a href="qlibrary-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QLibrary"><b>QLibrary</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename )</div></li><li><div class=fn>virtual <a href="#~QLibrary"><b>~QLibrary</b></a> ()</div></li><li><div class=fn>void * <a href="#resolve"><b>resolve</b></a> ( const&nbsp;char&nbsp;*&nbsp;symb )</div></li><li><div class=fn>bool <a href="#load"><b>load</b></a> ()</div></li><li><div class=fn>virtual bool <a href="#unload"><b>unload</b></a> ()</div></li><li><div class=fn>bool <a href="#isLoaded"><b>isLoaded</b></a> () const</div></li><li><div class=fn>bool <a href="#autoUnload"><b>autoUnload</b></a> () const</div></li><li><div class=fn>void <a href="#setAutoUnload"><b>setAutoUnload</b></a> ( bool&nbsp;enabled )</div></li><li><div class=fn>QString <a href="#library"><b>library</b></a> () const</div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>void * <a href="#resolve-2"><b>resolve</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename, const&nbsp;char&nbsp;*&nbsp;symb )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2><p> The QLibrary class provides a wrapper for handling shared libraries.<p> <p> An instance of a QLibrary object can handle a single shared libraryand provide access to the functionality in the library in a platformindependent way. If the library is a component server, QLibraryprovides access to the exported component and can directly querythis component for interfaces.<p> QLibrary ensures that the shared library is loaded and stays inmemory whilst it is in use. QLibrary can also unload the libraryon destruction and release unused resources.<p> A typical use of QLibrary is to resolve an exported symbol in ashared object, and to e.g. call the function that this symbolrepresents. This is called "explicit linking" in contrast to"implicit linking", which is done by the link step in the buildprocess when linking an executable against a library.<p> The following code snippet loads a library, resolves the symbol"mysymbol", and calls the function if everything succeeded. Ifsomething went wrong, e.g. the library file does not exist or thesymbol is not defined, the function pointer will become a nullpointer. Upon destruction of the QLibrary object the library will beunloaded, making all references to memory allocated in the libraryinvalid.<p> <pre>  typedef void (*MyPrototype)();  MyPrototype myFunction;  QLibrary myLib( "mylib" );  myFunction = (MyProtoype) myLib.<a href="#resolve">resolve</a>( "mysymbol" );  if ( myFunction ) {      myFunction();  }  </pre> <hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QLibrary"></a>QLibrary::QLibrary ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename )</h3>Creates a QLibrary object for the shared library <em>filename</em>. The library will be unloaded in the destructor.<p> Note that <em>filename</em> does not need to include the (platform specific)file extension, so calling<pre>  QLibrary lib( "mylib" );  </pre> is equivalent to calling<pre>  QLibrary lib( "mylib.dll" );  </pre> on Windows. Specifying the extension is not recommended, since doingso introduces a platform dependency.<p> If <em>filename</em> does not include a path, the library loader will look forthe file in the platform specific search paths.<p> <p>See also <a href="#load">load</a>(), <a href="#unload">unload</a>() and <a href="#setAutoUnload">setAutoUnload</a>().<h3 class=fn><a name="~QLibrary"></a>QLibrary::~QLibrary ()<tt> [virtual]</tt></h3>Deletes the QLibrary object.<p> The library will be unloaded if <a href="#autoUnload">autoUnload</a>() is TRUE (the default), otherwiseit stays in memory until the application is exited.<p> <p>See also <a href="#unload">unload</a>() and <a href="#setAutoUnload">setAutoUnload</a>().<h3 class=fn>bool <a name="autoUnload"></a>QLibrary::autoUnload () const</h3>Returns TRUE if the library will be automatically unloaded when this wrapperobject is destructed; otherwise returns FALSE. The default is TRUE.<p> <p>See also <a href="#setAutoUnload">setAutoUnload</a>().<h3 class=fn>bool <a name="isLoaded"></a>QLibrary::isLoaded () const</h3>Returns TRUE if the library is loaded; otherwise returns FALSE.<p> <p>See also <a href="#unload">unload</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="library"></a>QLibrary::library () const</h3>Returns the filename of the shared library this QLibrary object handles,including the platform specific file extension.<p> For example:<pre>  QLibrary lib( "mylib" );  <a href="qstring.html">QString</a> str = lib.<a href="#library">library</a>();  </pre> <p> will set <em>str</em> to "mylib.dll" on Windows, and "libmylib.so" on Linux.<h3 class=fn>bool <a name="load"></a>QLibrary::load ()</h3>Loads the library. Since <a href="#resolve">resolve</a>() always calls this function before resolvingany symbols it is not necessary to call this function explicitly. Insome situations you might want the library loaded in advance, inwhich case you would call this function.<h3 class=fn>void * <a name="resolve"></a>QLibrary::resolve ( const&nbsp;char&nbsp;*&nbsp;symb )</h3>Returns the address of the exported symbol <em>symb</em>. The library isloaded if necessary. The function returns a null pointer if the symbolcould not be resolved or the library could not be loaded.<p> <pre>  typedef int (*avgProc)( int, int );  avgProc avg = (avgProc) library-&gt;resolve( "avg" );  if ( avg )      return avg( 5, 8 );  else      return -1;  </pre> <p> <h3 class=fn>void * <a name="resolve-2"></a>QLibrary::resolve ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename, const&nbsp;char&nbsp;*&nbsp;symb )<tt> [static]</tt></h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Loads the library <em>filename</em> and returns the address of theexported symbol <em>symb</em>. Note that like the constructor, <em>filename</em> does not need to include the (platform specific) fileextension. The library remains loaded until the process exits.<p> The function returns a null pointer if the symbol could not beresolved or the library could not be loaded.<p> This function is useful only if you want to resolve a singlesymbol, e.g. a function pointer from a specific library once:<p> <pre>  typedef void (*FunctionType)();  static FunctionType *ptrFunction = 0;  static bool triedResolve = FALSE;  if ( !ptrFunction &amp;&amp; !triedResolve )      ptrFunction = QLibrary::<a href="#resolve">resolve</a>( "foo", "function" );  if ( ptrFunction )      ptrFunction();  else      ...  </pre> <p> If you want to resolve multiple symbols, use a QLibrary objectand call the non-static version of <a href="#resolve">resolve</a>().<p> <p>See also <h3 class=fn>void <a name="setAutoUnload"></a>QLibrary::setAutoUnload ( bool&nbsp;enabled )</h3>If <em>enabled</em> is TRUE (the default), the wrapper object is set to automatically unload the library upon destruction. If <em>enabled</em> is FALSE, the wrapper object is not unloaded unless you explicitly call<a href="#unload">unload</a>().<p> <p>See also <a href="#autoUnload">autoUnload</a>().<h3 class=fn>bool <a name="unload"></a>QLibrary::unload ()<tt> [virtual]</tt></h3>Unloads the library and returns TRUE if the library could be unloaded;otherwise returns FALSE.<p> This function is called by the destructor if <a href="#autoUnload">autoUnload</a>() is enabled.<p> <p>See also <a href="#resolve">resolve</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright &copy; 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

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