[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/misc.doc:37 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>Brief Technical FAQ</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Brief Technical FAQ</h1>
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | This document describes how to use more than one Qt version on one
|
---|
| 36 | machine and how to use Qt on X11 without a window manager. In addition
|
---|
| 37 | it explains the most common source of link errors with Qt.
|
---|
| 38 | <p> Other frequently asked questions can be found in the
|
---|
| 39 | <a href="http://www.trolltech.com/developer/faqs/">FAQ index</a> and
|
---|
| 40 | in the <a href="http://www.trolltech.com/developer/faqs/technical.html">Technical FAQ</a>.
|
---|
| 41 | <p> <ul>
|
---|
| 42 | <li> <a href="#linkerror">Link error, complaining about a lack of
|
---|
| 43 | <tt>vtbl</tt>, <tt>_vtbl</tt>, <tt>__vtbl</tt> or similar</a>
|
---|
| 44 | <li> <a href="#diffver">Using different versions of Qt on the same
|
---|
| 45 | machine</a>
|
---|
| 46 | <ul>
|
---|
| 47 | <li> <a href="#qtbin">Developers building for a single version of Qt on Unix - Qt binary packages</a>
|
---|
| 48 | <li> <a href="#qtsrc">Developers building for two versions of Qt on Unix - Qt sources</a>
|
---|
| 49 | </ul>
|
---|
| 50 | <li> <a href="#nowinman">Using Qt on X11 without a window manager</a>
|
---|
| 51 | <li> <a href="distributingqt.html">Distributing Qt Applications</a>
|
---|
| 52 | </ul>
|
---|
| 53 | <p> <a name="linkerror"></a>
|
---|
| 54 | <h2> Link error, complaining about a lack of <tt>vtbl</tt>, <tt>_vtbl</tt>, <tt>__vtbl</tt> or similar
|
---|
| 55 | </h2>
|
---|
| 56 | <a name="1"></a><p> This indicates that you've included the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro in a class
|
---|
| 57 | declaration and probably also run the <a href="moc.html#moc">moc</a>, but forgot to link the
|
---|
| 58 | moc-generated object code into your executable. See <a href="moc.html">Using the Meta Object Compiler</a> for details on how to use moc.
|
---|
| 59 | <p> <a name="diffver"></a>
|
---|
| 60 | <h2> Using different versions of Qt on the same machine
|
---|
| 61 | </h2>
|
---|
| 62 | <a name="2"></a><p> Qt programs need the following components of a Qt distribution:
|
---|
| 63 | <p> <dl>
|
---|
| 64 | <p> <dt>Header files - Compile time
|
---|
| 65 | <p> <dd>Programmers need to include the Qt header files. The Qt header files
|
---|
| 66 | are usually located in the <tt>include</tt> subdirectory of Qt distributions.
|
---|
| 67 | Care must be taken to include the header files of the relevant release of
|
---|
| 68 | Qt. Those with a command-line compiler will typically use options such as
|
---|
| 69 | <tt>/I%QTDIR%\include</tt>
|
---|
| 70 |
|
---|
| 71 | the relevant release of Qt.
|
---|
| 72 | <p> <dt>Meta Object Compiler and other tools - Compile time
|
---|
| 73 | <p> <dd>Programmers need to run <em>moc</em> and other tools such as <em>uic</em>. These
|
---|
| 74 | tools are usually located in the <tt>bin</tt> subdirectory of Qt distributions.
|
---|
| 75 | Either run <tt>"$QTDIR"/bin/moc</tt> and <tt>"$QTDIR"/bin/uic</tt> or add <tt>"$QTDIR"/bin</tt>
|
---|
| 76 | to your <tt>PATH</tt> and run <a href="moc.html#moc">moc</a> and <tt>uic</tt>. If you use <tt>qmake</tt> the
|
---|
| 77 | appropriate lines will be added to your Makefiles so that <em>uic</em> and
|
---|
| 78 | <em>moc</em> will be executed as required.
|
---|
| 79 | <p> <dt>Static or shared libraries - Link time
|
---|
| 80 | <p> <dd>Programmers need to link with the Qt static or shared libraries. The Qt
|
---|
| 81 | libraries are usually located in the <tt>lib</tt> subdirectory of Qt distributions.
|
---|
| 82 | Care must be taken to link with the libraries of the relevant release of
|
---|
| 83 | Qt. Those with a command-line compiler will typically use options such as
|
---|
| 84 | <tt>/L%QTDIR%\lib\qt.lib</tt> or <tt>-L"$QTDIR"/lib</tt> <tt>-lqt</tt> provided <tt>QTDIR</tt>
|
---|
| 85 | specifies the relevant release of Qt.
|
---|
| 86 | <p> <dt>Shared libraries - Run time
|
---|
| 87 | <p> <dd>Users of programs linked with shared Qt libraries need these same
|
---|
| 88 | shared libraries to run these programs. The Qt libraries are usually
|
---|
| 89 | located in the <tt>lib</tt> subdirectory of Qt distributions. Shared libraries
|
---|
| 90 | are made available to programs in places such as <tt>C:\windows\system</tt> on
|
---|
| 91 | Windows platforms, directories listed in file <tt>/etc/ld.so.conf</tt> on Linux,
|
---|
| 92 | standard <tt>lib</tt> directories on Unix, or directories listed in environment
|
---|
| 93 | variables <tt>LD_LIBRARY_PATH</tt>, <tt>SHLIB_PATH</tt>, or <tt>LIBPATH</tt> on various Unix
|
---|
| 94 | flavours. Make the relevant Qt libraries available using one of these
|
---|
| 95 | mechanisms.
|
---|
| 96 | <p> </dl>
|
---|
| 97 | <p> Qt distributions consist of different files needed at compile time,
|
---|
| 98 | link time, or run time. Trolltech distributes Qt in the form of a
|
---|
| 99 | source package that contain all these files once they have been built.
|
---|
| 100 | <p> Other vendors distribute Qt in the form of binary packages. Binary packages
|
---|
| 101 | usually consist of two parts:
|
---|
| 102 | <p> <ul>
|
---|
| 103 | <li> shared libraries in the run time package, usually called <tt>qt3</tt>.
|
---|
| 104 | <p> <li> header files, static libraries, the moc and other tools in the developers'
|
---|
| 105 | kit, usually called <tt>qt3-dev</tt>.
|
---|
| 106 | <p> </ul>
|
---|
| 107 | <p> Depending on how you are using Qt, you need to make specific parts of
|
---|
| 108 | the Qt distribution available to your programs. Typical situations are
|
---|
| 109 | described below.
|
---|
| 110 | <p> <a name="qtbin"></a>
|
---|
| 111 | <h3> Developers building for a single version of Qt on Unix - Qt binary packages
|
---|
| 112 | </h3>
|
---|
| 113 | <a name="2-1"></a><p> You build programs with a single version of Qt, but you still need
|
---|
| 114 | to run programs linked with another version of Qt. You are typically
|
---|
| 115 | a Linux developer who builds programs for Qt 3.x on a KDE desktop based
|
---|
| 116 | on Qt 2.x. Qt packages are usually split into a shared library
|
---|
| 117 | package with a name like <tt>qt</tt> and a developer package with a name
|
---|
| 118 | like <tt>qt-dev</tt>. You will need the appropriate packages:
|
---|
| 119 | <p> <ul>
|
---|
| 120 | <p> <li> To build programs you will need the header files, the libraries,
|
---|
| 121 | the moc and other tools from Qt 3.x. They are included in the developer
|
---|
| 122 | package of Qt 3.x (<tt>qt3-dev</tt> or similar).
|
---|
| 123 | <p> <li> To run programs you will need the shared libraries of Qt 3.x and
|
---|
| 124 | Qt 2.x. They are included in the regular packages of Qt 3.x (<tt>qt3</tt>
|
---|
| 125 | or similar) and Qt 2.x (<tt>qt2</tt> or similar).
|
---|
| 126 | <p> </ul>
|
---|
| 127 | <p> Just install the packages, <tt>qt2</tt>, <tt>qt3</tt>, and <tt>qt3-dev</tt>. You may
|
---|
| 128 | need to set the environment variable <tt>QTDIR</tt> to point to Qt 3.x.
|
---|
| 129 | <p> <a name="qtsrc"></a>
|
---|
| 130 | <h3> Developers building for two versions of Qt on Unix - Qt sources
|
---|
| 131 | </h3>
|
---|
| 132 | <a name="2-2"></a><p> You build and run programs for Qt 2.x and Qt 3.x. You will need:
|
---|
| 133 | <p> <ul>
|
---|
| 134 | <p> <li> the header files, the libraries, the moc and other tools from Qt 3.x
|
---|
| 135 | and Qt 2.x to build programs,
|
---|
| 136 | <p> <li> the shared libraries of Qt 3.x and Qt 2.x to run programs.
|
---|
| 137 | <p> </ul>
|
---|
| 138 | <p> Get the source distributions of both Qt 2.x and Qt 3.x.
|
---|
| 139 | <p> <ol type=1>
|
---|
| 140 | <p> <li> Install and build Qt 2.x and Qt 3.x, usually in <tt>/opt</tt> or
|
---|
| 141 | <tt>/usr/local</tt>. In the case of <tt>/opt</tt>:
|
---|
| 142 | <p> <pre>
|
---|
| 143 | $ cd /opt
|
---|
| 144 | $ gunzip -c \c qt-x11-2.3.1.tar.gz | tar xf -
|
---|
| 145 | $ cd qt-2.3.1
|
---|
| 146 | $ setenv QTDIR /opt/qt-2.3.1
|
---|
| 147 | $ configure [options]
|
---|
| 148 | $ make
|
---|
| 149 |
|
---|
| 150 | $ cd /opt
|
---|
| 151 | $ gunzip -c qt-x11-free-3.0.0.tar.gz | tar xf -
|
---|
| 152 | $ cd qt-3.0.0
|
---|
| 153 | $ setenv QTDIR /opt/qt-3.0.0
|
---|
| 154 | $ configure [options]
|
---|
| 155 | $ make
|
---|
| 156 | </pre>
|
---|
| 157 |
|
---|
| 158 | <p> <li> Make shared libraries available to programs at run time. Either
|
---|
| 159 | add both <tt>/opt/qt-2.3.1/lib</tt> and <tt>/opt/qt-3.0.0/lib</tt> to your environment
|
---|
| 160 | variable <tt>LD_LIBRARY_PATH</tt> or file <tt>/etc/ld.so.conf</tt> or whataver mechanism
|
---|
| 161 | you're using, or make links to the libraries in a standard directory like
|
---|
| 162 | <tt>/usr/local/lib</tt>:
|
---|
| 163 | <p> <pre>
|
---|
| 164 | cd /usr/local/lib
|
---|
| 165 | ln -s /opt/qt-2.3.1/lib/libqt.so.2 .
|
---|
| 166 | ln -s /opt/qt-2.3.1/lib/libqt-mt.so.2 .
|
---|
| 167 | ln -s /opt/qt-2.3.1/lib/libqutil.so.1 .
|
---|
| 168 | ln -s /opt/qt-3.0.0/lib/libqt.so.3 .
|
---|
| 169 | ln -s /opt/qt-3.0.0/lib/libqui.so.1 .
|
---|
| 170 | </pre>
|
---|
| 171 |
|
---|
| 172 | <p> </ol>
|
---|
| 173 | <p> To develop with Qt 2.x use:
|
---|
| 174 | <p> <pre>
|
---|
| 175 | setenv QTDIR /opt/qt-2.3.1
|
---|
| 176 | setenv PATH ${QTDIR}/bin:${PATH}
|
---|
| 177 | </pre>
|
---|
| 178 |
|
---|
| 179 | <p> To develop with Qt 3.x use:
|
---|
| 180 | <p> <pre>
|
---|
| 181 | setenv QTDIR /opt/qt-3.0.0
|
---|
| 182 | setenv PATH ${QTDIR}/bin:${PATH}
|
---|
| 183 | </pre>
|
---|
| 184 |
|
---|
| 185 | <p> Setting <tt>QTDIR</tt> ensures that the proper resources are used, such as the
|
---|
| 186 | documentation appropriate to the version of Qt you're using. Also
|
---|
| 187 | your Makfiles may refer to <tt>"$QTDIR"/include</tt> and <tt>"$QTDIR"/lib</tt> to
|
---|
| 188 | include the proper header files and link with the proper libraries.
|
---|
| 189 | Setting the <tt>PATH</tt> ensures that the proper version of moc and other
|
---|
| 190 | tools is being used.
|
---|
| 191 | <p> <a name="nowinman"></a>
|
---|
| 192 | <h2> Using Qt on X11 without a window manager
|
---|
| 193 | </h2>
|
---|
| 194 | <a name="3"></a><p> When using Qt without a window manager on Unix/X11, you will most
|
---|
| 195 | likely experience focus problems. Without a window manager, there is
|
---|
| 196 | no focus handling on X11, and no concept of an active window
|
---|
| 197 | either. If you want your application to work in such an environment,
|
---|
| 198 | you have to explicitly mark a window as active <em>after</em> showing it:
|
---|
| 199 | <p> <pre>
|
---|
| 200 | yourWindow->show();
|
---|
| 201 | yourWindow->setActiveWindow();
|
---|
| 202 | </pre>
|
---|
| 203 |
|
---|
| 204 | <p> Note that setActiveWindow() won't work if the widget does not become
|
---|
| 205 | physically visible during this event cycle. However, without a window
|
---|
| 206 | manager running, this is guaranteed to happen. For the curious reader:
|
---|
| 207 | setActiveWindow() emulates a window manager by explicitly setting the
|
---|
| 208 | X Input Focus to a widget's top level window.
|
---|
| 209 | <p>
|
---|
| 210 | <!-- eof -->
|
---|
| 211 | <p><address><hr><div align=center>
|
---|
| 212 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 213 | <td>Copyright © 2007
|
---|
| 214 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 215 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 216 | </table></div></address></body>
|
---|
| 217 | </html>
|
---|