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

📄 commonproblems.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/doc/misc.doc:92 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>FAQs</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>FAQs</h1> This document describes how to use more than one Qt version on onemachine and how to use Qt on X11 without a window manager. In additionit explains the most common source of link errors with Qt.<p> Other frequently asked questions can be found in the<a href="http://www.trolltech.com/developer/faqs/">FAQ index</a> andin the <a href="http://www.trolltech.com/developer/faqs/technical.html">Technical FAQ</a>.<p> <ul><li> <a href="#linkerror">Link error, complaining about a lack of &#92;c vtbl, &#92;c _vtbl, &#92;c __vtbl or similar</a><li> <a href="#diffver">Using different versions of Qt on the samemachine</a><ul><li> <a href="#qtbin">Developers building for a single version of Qt on Unix - Qt binary packages</a><li> <a href="#qtsrc">Developers building for two versions of Qt on Unix - Qt sources</a></ul><li> <a href="#nowinman">Using Qt on X11 without a window manager</a></ul><p> <a name="linkerror"></a><h2> Link error, complaining about a lack of <tt>vtbl</tt>, <tt>_vtbl</tt>, <tt>__vtbl</tt> or similar</h2><a name="1"></a><p> This indicates that you've included the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro in a classdeclaration and probably also run the <a href="moc.html#moc">moc</a>, but forgot to link themoc-generated object code into your executable. See <a href="moc.html">Using the Meta Object Compiler</a> for details on how to use moc.<p> <a name="diffver"></a><h2> Using different versions of Qt on the same machine</h2><a name="2"></a><p> Qt programs need the following components of a Qt distribution:<p> <dl><p> <dt>Header files - Compile time<p> <dd>Programmers need to include the Qt header files.  The Qt header filesare usually located in the <tt>include</tt> subdirectory of Qt distributions.Care must be taken to include the header files of the relevant release ofQt. Those with a command-line compiler will typically use options such as<tt>/I%QTDIR%&#92;include</tt>the relevant release of Qt.<p> <dt>Meta Object Compiler and other tools - Compile time<p> <dd>Programmers need to run <em>moc</em> and other tools such as <em>uic</em>. Thesetools are usually located in the <tt>bin</tt> subdirectory of Qt distributions.Either run <tt>"$QTDIR"/bin/moc</tt> and <tt>"$QTDIR"/bin/uic</tt> or add <tt>"$QTDIR"/bin</tt>to your <tt>PATH</tt> and run <a href="moc.html#moc">moc</a> and <tt>uic</tt>. If you use <tt>qmake</tt> theappropriate lines will be added to your Makefiles so that <em>uic</em> and<em>moc</em> will be executed as required.<p> <dt>Static or shared libraries - Link time<p> <dd>Programmers need to link with the Qt static or shared libraries. The Qtlibraries are usually located in the <tt>lib</tt> subdirectory of Qt distributions.Care must be taken to link with the libraries of the relevant release ofQt.  Those with a command-line compiler will typically use options such as<tt>/L%QTDIR%&#92;lib&#92;qt.lib</tt> or <tt>-L"$QTDIR"/lib</tt> <tt>-lqt</tt> provided <tt>QTDIR</tt>specifies the relevant release of Qt.<p> <dt>Shared libraries - Run time<p> <dd>Users of programs linked with shared Qt libraries need these sameshared libraries to run these programs.  The Qt libraries are usuallylocated in the <tt>lib</tt> subdirectory of Qt distributions.  Shared librariesare made available to programs in places such as <tt>C:&#92;windows&#92;system</tt> onWindows platforms, directories listed in file <tt>/etc/ld.so.conf</tt> on Linux,standard <tt>lib</tt> directories on Unix, or directories listed in environmentvariables <tt>LD_LIBRARY_PATH</tt>, <tt>SHLIB_PATH</tt>, or <tt>LIBPATH</tt> on various Unixflavours.  Make the relevant Qt libraries available using one of thesemechanisms.<p> </dl><p> Qt distributions consist of different files needed at compile time,link time, or run time. Trolltech distributes Qt in the form of asource package that contain all these files once they have been built.<p> Other vendors distribute Qt in the form of binary packages. Binary packagesusually consist of two parts:<p> <ul><li> shared libraries in the run time package, usually called <tt>qt3</tt>.<p> <li> header files, static libraries, the moc and other tools in the developers'kit, usually called <tt>qt3-dev</tt>.<p> </ul><p> Depending on how you are using Qt, you need to make specific parts ofthe Qt distribution available to your programs.  Typical situations aredescribed below.<p> <a name="qtbin"></a><h3> Developers building for a single version of Qt on Unix - Qt binary packages</h3><a name="2-1"></a><p> You build programs with a single version of Qt, but you still needto run programs linked with another version of Qt.  You are typicallya Linux developer who builds programs for Qt 3.x on a KDE desktop basedon Qt 2.x.  Qt packages are usually split into a shared librarypackage with a name like <tt>qt</tt> and a developer package with a namelike <tt>qt-dev</tt>.  You will need the appropriate packages:<p> <ul><p> <li> To build programs you will need the header files, the libraries,the moc and other tools from Qt 3.x. They are included in the developerpackage of Qt 3.x (<tt>qt3-dev</tt> or similar).<p> <li> To run programs you will need the shared libraries of Qt 3.x andQt 2.x.  They are included in the regular packages of Qt 3.x (<tt>qt3</tt>or similar) and Qt 2.x (<tt>qt2</tt> or similar).<p> </ul><p> Just install the packages, <tt>qt2</tt>, <tt>qt3</tt>, and <tt>qt3-dev</tt>. You mayneed to set the environment variable <tt>QTDIR</tt> to point to Qt 3.x.<p> <a name="qtsrc"></a><h3> Developers building for two versions of Qt on Unix - Qt sources</h3><a name="2-2"></a><p> You build and run programs for Qt 2.x and Qt 3.x. You will need:<p> <ul><p> <li> the header files, the libraries, the moc and other tools from Qt 3.xand Qt 2.x to build programs,<p> <li> the shared libraries of Qt 3.x and Qt 2.x to run programs.<p> </ul><p> Get the source distributions of both Qt 2.x and Qt 3.x.<p> <ol type=1><p> <li> Install and build Qt 2.x and Qt 3.x, usually in <tt>/opt</tt> or<tt>/usr/local</tt>. In the case of <tt>/opt</tt>:<p> <pre>$ cd /opt$ gunzip -c \c qt-x11-2.3.1.tar.gz | tar xf -$ cd qt-2.3.1$ setenv QTDIR /opt/qt-2.3.1$ configure [options]$ make$ cd /opt$ gunzip -c qt-x11-free-3.0.0.tar.gz | tar xf -$ cd qt-3.0.0$ setenv QTDIR /opt/qt-3.0.0$ configure [options]$ make</pre> <p> <li> Make shared libraries available to programs at run time. Eitheradd both <tt>/opt/qt-2.3.1/lib</tt> and <tt>/opt/qt-3.0.0/lib</tt> to your environmentvariable <tt>LD_LIBRARY_PATH</tt> or file <tt>/etc/ld.so.conf</tt> or whataver mechanismyou're using, or make links to the libraries in a standard directory like<tt>/usr/local/lib</tt>:<p> <pre>cd /usr/local/libln -s /opt/qt-2.3.1/lib/libqt.so.2 .ln -s /opt/qt-2.3.1/lib/libqt-mt.so.2 .ln -s /opt/qt-2.3.1/lib/libqutil.so.1 .ln -s /opt/qt-3.0.0/lib/libqt.so.3 .ln -s /opt/qt-3.0.0/lib/libqui.so.1 .</pre> <p> </ol><p> To develop with Qt 2.x use:<p> <pre>setenv QTDIR /opt/qt-2.3.1setenv PATH ${QTDIR}/bin:${PATH}</pre> <p> To develop with Qt 3.x use:<p> <pre>setenv QTDIR /opt/qt-3.0.0setenv PATH ${QTDIR}/bin:${PATH}</pre> <p> Setting <tt>QTDIR</tt> ensures that the proper resources are used, such as thedocumentation appropriate to the version of Qt you're using.  Alsoyour Makfiles may refer to <tt>"$QTDIR"/include</tt> and <tt>"$QTDIR"/lib</tt> toinclude the proper header files and link with the proper libraries.Setting the <tt>PATH</tt> ensures that the proper version of moc and othertools is being used.<p> <a name="nowinman"></a><h2> Using Qt on X11 without a window manager</h2><a name="3"></a><p> When using Qt without a window manager on Unix/X11, you will mostlikely experience focus problems. Without a window manager, there isno focus handling on X11, and no concept of an active windoweither. If you want your application to work in such an environment,you have to explicitly mark a window as active <em>after</em> showing it:<p> <pre> yourWindow-&gt;show(); yourWindow-&gt;setActiveWindow();</pre> <p> Note that setActiveWindow() won't work if the widget does not becomephysically visible during this event cycle. However, without a windowmanager running, this is guaranteed to happen. For the curious reader:setActiveWindow() emulates a window manager by explicitly setting theX Input Focus to a widget's top level window.<p> <!-- eof --><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 + -