File: commonproblems.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (186 lines) | stat: -rw-r--r-- 7,603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Qt Toolkit -  Common Problems</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: white; color: black; }
--></style></head><body bgcolor="#ffffff">
<p>
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center> Common Problems</h1><br clear="all">
<h2>Link error, complaining about a lack of <code>vtbl,</code> <code>_vtbl,</code> <code>__vtbl</code> or similar </h2>
<p>
This indicates that you include the Q_OBJECT macro in a class declaration
and probably also run the moc, but forget to link the moc-generated object
code into your executable. Read <a href="moc.html">Using the Meta Object
Compiler</a> for details on how to use moc.
<p>
<h2>Using different versions of Qt on the same machine</h2>
<p>
Qt programs need the following components of the Qt distribution: <dl>
<p>
<dt><b>Header files - Compile time</b>
<p>
<dd>Programmers need to include the Qt header files. Those with a
command-line compiler will typically use options such as <code>/I%QTDIR%\include</code> or <code>-I${QTDIR}/include.</code>  They will need the header
files of the version of Qt they wish to build programs with.  The
header files are in the <code>include</code> subdirectory of Qt distributions.
<p>
<dt><b>Meta Object Compiler - Compile time</b>
<p>
<dd>Programmers need to run the Meta Object Compiler - <em>moc.</em>  The moc is
found in the <code>bin</code> subdirectory of Qt distributions.
<p>
<dt><b>Static or shared libraries - Link time</b>
<p>
<dd>Programmers need to link with static or shared libraries. Those with a
command-line compiler will typically use options such as <code>/L%QTDIR%\lib\qt.lib</code> or <code>-L${QTDIR}/lib</code> <code>-lqt.</code>  They will need the
libraries of the version of Qt they wish to build programs with.  The
libraries are in the <code>lib</code> subdirectory of Qt distributions.
<p>
<dt><b>Shared libraries - Run time</b>
<p>
<dd>Users of programs built with the shared Qt libraries need these same
shared libraries to run the programs.  The libraries are in the <code>lib</code>
subdirectory of Qt distributions.  Shared libraries are made available
to programs in places such as <code>C:\windows\system</code> on Windows
platforms, directories listed in file <code>/etc/ld.so.conf</code> on Linux,
standard <code>lib</code> directories on Unix, or the directories listed in the
environment variable <code>${LD_LIBRARY_PATH}</code> on Unix/Linux.
<p>
</dl>
<p>
Binary packages usually consist of two parts:
<p>
<ul>
<li>run time libraries in the run time package, usually called
<code>qt2.</code>
<li>header files, the moc and static libraries in the developers' kit,
usually called <code>qt2-dev.</code>
<p>
</ul>
<p>
Depending on how you are using Qt, you need to make specific parts of
the Qt distribution available to your programs.  Typical situations are
described below.<dl>
<p>
<dt><b>Developers building for a single version of Qt on Unix
- Qt packages</b>
<p>
<dd>You build programs with a single version of Qt, but you still need
to run programs linked with another version of Qt.  You are typically
a Linux developer who builds programs for Qt 2.x on a KDE desktop based
on Qt 1.4x.  Qt packages are usually split into a shared library
package with a name like <code>qt</code> and a developer package with a name
like <code>qt-dev.</code>  You will need the appropriate packages:
<p>
<ul>
<li>To build programs you will need the header files, the moc and the
libraries of Qt 2.x. They are included in the developer package of
Qt 2.x (<code>qt2-dev</code> or the like).
<li>To run programs you will need the shared libraries of Qt 2.x
and Qt 1.4x. They are included in the regular packages
of Qt 2.x (<code>qt2</code> or the like) and Qt 1.4x (<code>qt1</code>
or the like).
<p>
</ul>Just install those 3 packages. You may need to set the
environment variable <code>QTDIR.</code>
<p>
<dt><b>Developers building for two versions of Qt on Unix
- Qt sources</b>
<p>
<dd>You build and run programs for Qt v1.4x and Qt 2.x. You will need:<ul>
<li>the <em>header</em> <em>files,</em> the <em>moc</em> and the <em>libraries</em> of Qt 2.x
and Qt 1.4x to build programs,
<li>the shared libraries of Qt 2.x and Qt 1.4x to run programs (if you
use shared linking).
<p>
</ul>
<p>
Get source distributions of both Qt 1.4x and Qt 2.x. <ol>
<li>Install and build Qt 1.4x and Qt 2.x, usually in <code>/opt</code> or
<code>/usr/local.</code> In the case of <code>/opt:</code>
<p>
<pre>$ cd /opt
$ gunzip -c qt-1.44.tar.gz | tar xf -
$ cd qt-1.44
$ setenv QTDIR /opt/qt-1.44
$ configure [options]
$ make

$ cd /opt
$ gunzip -c qt-2.1.0.tar.gz | tar xf -
$ cd qt-2.1.0
$ setenv QTDIR /opt/qt-2.1.0
$ configure [options]
$ make
</pre>
<li>Make shared libraries available to programs at run time. Either
add both <code>/opt/qt-1.44</code> and <code>/opt/qt-2.0.1</code> to your environment
variable <code>LD_LIBRARY_PATH</code> or make links to the libraries in a
standard directory like <code>/usr/local/lib:</code>
<p>
<pre>cd /usr/local/lib
ln -s /opt/qt-1.44/lib/libqt.so.1 .
ln -s /opt/qt-2.1.0/lib/libqt.so.2 .
</pre>
<p>
</ol>
<p>
To develop with Qt 1.4x use:
<p>
<pre>setenv QTDIR /opt/qt-1.44
setenv PATH ${QTDIR}/bin:${PATH}
</pre>
<p>
To develop with Qt 2.x use:
<p>
<pre>setenv QTDIR /opt/qt-2.1.0
setenv PATH ${QTDIR}/bin:${PATH}
</pre>
<p>
Setting the <code>PATH</code> ensures that the proper version of moc is being
used.  Your <code>Makefile</code> should refer to <code>${QTDIR}/include</code> and <code>${QTDIR}/lib</code> to include the proper header files and link with the
proper libraries.
<p>
</dl>
<p>
<h2>Using Qt on X11 without a window manager</h2>
<p>
When using Qt without a window manager on Unix/X11, you will very
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 toplevel window.
<p>
<h2>Other common problems</h2>
<p>
Other common problems are covered by the online
<a href="http://www.trolltech.com/faq/tech.html">Technical FAQ</a>.

<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>