You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/commonproblems.html

218 lines
9.9 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/misc.doc:37 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Brief Technical FAQ</title>
<style type="text/css"><!--
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>Brief Technical FAQ</h1>
This document describes how to use more than one TQt version on one
machine and how to use TQt on X11 without a window manager. In addition
it explains the most common source of link errors with TQt.
<p> Other frequently asked questions can be found in the
<a href="http://www.trolltech.com/developer/faqs/">FAQ index</a> and
in 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
<tt>vtbl</tt>, <tt>_vtbl</tt>, <tt>__vtbl</tt> or similar</a>
<li> <a href="#diffver">Using different versions of TQt on the same
machine</a>
<ul>
<li> <a href="#qtbin">Developers building for a single version of TQt on Unix - TQt binary packages</a>
<li> <a href="#qtsrc">Developers building for two versions of TQt on Unix - TQt sources</a>
</ul>
<li> <a href="#nowinman">Using TQt on X11 without a window manager</a>
<li> <a href="distributingntqt.html">Distributing TQt Applications</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#TQ_OBJECT">TQ_OBJECT</a> macro in a class
declaration and probably also run the <a href="moc.html#moc">moc</a>, but forgot to link the
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.
<p> <a name="diffver"></a>
<h2> Using different versions of TQt on the same machine
</h2>
<a name="2"></a><p> TQt programs need the following components of a TQt distribution:
<p> <dl>
<p> <dt>Header files - Compile time
<p> <dd>Programmers need to include the TQt header files. The TQt header files
are usually located in the <tt>include</tt> subdirectory of TQt distributions.
Care must be taken to include the header files of the relevant release of
TQt. Those with a command-line compiler will typically use options such as
<tt>/I%TQTDIR%&#92;include</tt>
the relevant release of TQt.
<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>. These
tools are usually located in the <tt>bin</tt> subdirectory of TQt distributions.
Either run <tt>"$TQTDIR"/bin/moc</tt> and <tt>"$TQTDIR"/bin/uic</tt> or add <tt>"$TQTDIR"/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> the
appropriate 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 TQt static or shared libraries. The TQt
libraries are usually located in the <tt>lib</tt> subdirectory of TQt distributions.
Care must be taken to link with the libraries of the relevant release of
TQt. Those with a command-line compiler will typically use options such as
<tt>/L%TQTDIR%&#92;lib&#92;qt.lib</tt> or <tt>-L"$TQTDIR"/lib</tt> <tt>-lqt</tt> provided <tt>TQTDIR</tt>
specifies the relevant release of TQt.
<p> <dt>Shared libraries - Run time
<p> <dd>Users of programs linked with shared TQt libraries need these same
shared libraries to run these programs. The TQt libraries are usually
located in the <tt>lib</tt> subdirectory of TQt distributions. Shared libraries
are made available to programs in places such as <tt>C:&#92;windows&#92;system</tt> on
Windows platforms, directories listed in file <tt>/etc/ld.so.conf</tt> on Linux,
standard <tt>lib</tt> directories on Unix, or directories listed in environment
variables <tt>LD_LIBRARY_PATH</tt>, <tt>SHLIB_PATH</tt>, or <tt>LIBPATH</tt> on various Unix
flavours. Make the relevant TQt libraries available using one of these
mechanisms.
<p> </dl>
<p> TQt distributions consist of different files needed at compile time,
link time, or run time. Trolltech distributes TQt in the form of a
source package that contain all these files once they have been built.
<p> Other vendors distribute TQt in the form of binary packages. Binary packages
usually 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 TQt, you need to make specific parts of
the TQt distribution available to your programs. Typical situations are
described below.
<p> <a name="qtbin"></a>
<h3> Developers building for a single version of TQt on Unix - TQt binary packages
</h3>
<a name="2-1"></a><p> You build programs with a single version of TQt, but you still need
to run programs linked with another version of TQt. You are typically
a Linux developer who builds programs for TQt 3.x on a KDE desktop based
on TQt 2.x. TQt packages are usually split into a shared library
package with a name like <tt>qt</tt> and a developer package with a name
like <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 TQt 3.x. They are included in the developer
package of TQt 3.x (<tt>qt3-dev</tt> or similar).
<p> <li> To run programs you will need the shared libraries of TQt 3.x and
TQt 2.x. They are included in the regular packages of TQt 3.x (<tt>qt3</tt>
or similar) and TQt 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 may
need to set the environment variable <tt>TQTDIR</tt> to point to TQt 3.x.
<p> <a name="qtsrc"></a>
<h3> Developers building for two versions of TQt on Unix - TQt sources
</h3>
<a name="2-2"></a><p> You build and run programs for TQt 2.x and TQt 3.x. You will need:
<p> <ul>
<p> <li> the header files, the libraries, the moc and other tools from TQt 3.x
and TQt 2.x to build programs,
<p> <li> the shared libraries of TQt 3.x and TQt 2.x to run programs.
<p> </ul>
<p> Get the source distributions of both TQt 2.x and TQt 3.x.
<p> <ol type=1>
<p> <li> Install and build TQt 2.x and TQt 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 TQTDIR /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 TQTDIR /opt/qt-3.0.0
$ configure [options]
$ make
</pre>
<p> <li> Make shared libraries available to programs at run time. Either
add both <tt>/opt/qt-2.3.1/lib</tt> and <tt>/opt/qt-3.0.0/lib</tt> to your environment
variable <tt>LD_LIBRARY_PATH</tt> or file <tt>/etc/ld.so.conf</tt> or whataver mechanism
you're using, or make links to the libraries in a standard directory like
<tt>/usr/local/lib</tt>:
<p> <pre>
cd /usr/local/lib
ln -s /opt/qt-2.3.1/lib/libtqt.so.2 .
ln -s /opt/qt-2.3.1/lib/libtqt-mt.so.2 .
ln -s /opt/qt-2.3.1/lib/libqutil.so.1 .
ln -s /opt/qt-3.0.0/lib/libtqt.so.3 .
ln -s /opt/qt-3.0.0/lib/libtqui.so.1 .
</pre>
<p> </ol>
<p> To develop with TQt 2.x use:
<p> <pre>
setenv TQTDIR /opt/qt-2.3.1
setenv PATH ${TQTDIR}/bin:${PATH}
</pre>
<p> To develop with TQt 3.x use:
<p> <pre>
setenv TQTDIR /opt/qt-3.0.0
setenv PATH ${TQTDIR}/bin:${PATH}
</pre>
<p> Setting <tt>TQTDIR</tt> ensures that the proper resources are used, such as the
documentation appropriate to the version of TQt you're using. Also
your Makfiles may refer to <tt>"$TQTDIR"/include</tt> and <tt>"$TQTDIR"/lib</tt> to
include the proper header files and link with the proper libraries.
Setting the <tt>PATH</tt> ensures that the proper version of moc and other
tools is being used.
<p> <a name="nowinman"></a>
<h2> Using TQt on X11 without a window manager
</h2>
<a name="3"></a><p> When using TQt without a window manager on Unix/X11, you will most
likely experience focus problems. Without a window manager, there is
no focus handling on X11, and no concept of an active window
either. 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 become
physically visible during this event cycle. However, without a window
manager running, this is guaranteed to happen. For the curious reader:
setActiveWindow() emulates a window manager by explicitly setting the
X 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; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>