0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the documentation of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
/*!
|
|
43 |
\page qt4-intro.html
|
|
44 |
\title What's New in Qt 4
|
|
45 |
|
|
46 |
\startpage index.html Qt Reference Documentation
|
|
47 |
\nextpage The Tulip Container Classes
|
|
48 |
|
|
49 |
This document covers the most important differences between Qt 3
|
|
50 |
and Qt 4. Although it is not intended to be a comprehensive
|
|
51 |
porting guide, it tells you about the most important portability
|
|
52 |
issues that you may encounter. It also explains how to turn on Qt
|
|
53 |
3 compatibility support.
|
|
54 |
|
|
55 |
\tableofcontents
|
|
56 |
|
|
57 |
\section1 New Technologies in Qt 4
|
|
58 |
|
|
59 |
Qt 4 introduces the following core technologies:
|
|
60 |
|
|
61 |
\list
|
|
62 |
\o \l{The Tulip Container Classes}{Tulip}, a new set of template container classes.
|
|
63 |
|
|
64 |
\o \l{The Interview Framework}{Interview}, a model/view architecture for item views.
|
|
65 |
|
|
66 |
\o \l{The Arthur Paint System}{Arthur}, the Qt 4 painting framework.
|
|
67 |
|
|
68 |
\o \l{The Scribe Classes}{Scribe}, the Unicode text renderer with a public API
|
|
69 |
for performing low-level text layout.
|
|
70 |
|
|
71 |
\o \l{The Qt 4 Main Window Classes}{Mainwindow}, a modern action-based
|
|
72 |
mainwindow, toolbar, menu, and docking architecture.
|
|
73 |
|
|
74 |
\o The new \l{The New Qt Designer}{\QD} user interface design tool.
|
|
75 |
\endlist
|
|
76 |
|
|
77 |
\section1 Recent Additions to Qt 4
|
|
78 |
|
|
79 |
The following features have been added to Qt since the first release of Qt 4:
|
|
80 |
|
|
81 |
In Qt 4.5:
|
|
82 |
\list
|
|
83 |
\o The WebKit browser engine included with Qt has been
|
|
84 |
upgraded to the latest upstream (trunk) version of WebKit,
|
|
85 |
bringing the latest features and improvements to Qt applications.
|
|
86 |
\o Qt for Mac OS X has been substantially rewritten to use
|
|
87 |
Apple's Cocoa API, enabling Qt applications to be deployed on
|
|
88 |
64-bit Macintosh hardware.
|
|
89 |
\o The QtXmlPatterns module has been extended to cover XSLT, a
|
|
90 |
transformation language for XML documents.
|
|
91 |
\o Qt Script introduced its debugger,
|
|
92 |
providing error reporting for scripts, and to let users track down
|
|
93 |
bugs in their own scripts.
|
|
94 |
\o Qt 4.5 includes support for writing rich text documents as
|
|
95 |
OpenDocument files via the newly-introduced QTextDocumentWriter
|
|
96 |
class.
|
|
97 |
\o Qt Linguist can load and edit multiple translation
|
|
98 |
files simultaneously.
|
|
99 |
\o Support for ARGB top-level widgets (i.e., translucent
|
|
100 |
windows).
|
|
101 |
\endlist
|
|
102 |
|
|
103 |
In Qt 4.4:
|
|
104 |
\list
|
|
105 |
\o \l{QtWebkit Module}{Qt WebKit integration}, making it possible for developers
|
|
106 |
to use a fully-featured Web browser to display documents and access online
|
|
107 |
services.
|
|
108 |
\o A multimedia API provided by the \l{Phonon Overview}{Phonon Multimedia Framework}.
|
|
109 |
\o \l{QtXmlPatterns Module}{XQuery and XPath} support, providing facilities for
|
|
110 |
XML processing beyond that supported by the QtXml module.
|
|
111 |
\o Support for embedded widgets in \l{Graphics View} scenes.
|
|
112 |
\o The \l{Thread Support in Qt}{QtConcurrent framework} for
|
|
113 |
concurrent programming using Qt paradigms and threading features.
|
|
114 |
\o An \l{QtHelp Module}{improved help system} that can be used in conjunction
|
|
115 |
with Qt Assistant or as an independent help resource manager.
|
|
116 |
\o Printing system improvements, including the QPrinterInfo, QPrintPreviewWidget
|
|
117 |
and QPrintPreviewDialog classes.
|
|
118 |
\o Support for \l{Windows CE - Introduction to using Qt}{Qt for Windows CE} as
|
|
119 |
a mainstream Qt platform.
|
|
120 |
\o Improvements in performance of Qt for Embedded Linux and extended support for
|
|
121 |
display hardware.
|
|
122 |
\endlist
|
|
123 |
|
|
124 |
In Qt 4.3:
|
|
125 |
\list
|
|
126 |
\o Support for different \l{The Qt 4 Main Window Classes}{main window paradigms and styles},
|
|
127 |
such as those found in Visual Studio or KDevelop.
|
|
128 |
\o The \l{QtScript} module, providing support for application scripting with ECMAScript.
|
|
129 |
\o Improved graphics features, including an experimental Direct3D paint engine
|
|
130 |
and improved provision for hardware accelerated rendering with OpenGL, and
|
|
131 |
support for OpenGL ES in Qt for Embedded Linux.
|
|
132 |
\o \l{QSvgGenerator}{Scalable Vector Graphics (SVG) export}, allowing SVG drawings to
|
|
133 |
be created using the standard QPainter API.
|
|
134 |
\o Support for arbitrary matrix transformations and set operations on painter paths.
|
|
135 |
\o Native look and feel on Windows Vista; improved look and feel on Mac OS X.
|
|
136 |
\o An improved \l{QMdiArea}{Multiple Document Interface (MDI)} implementation.
|
|
137 |
\o Continuous improvements to \QD, including support for
|
|
138 |
\l{Qt Designer's Widget Editing Mode#The Property Editor}{dynamic properties}.
|
|
139 |
\o Support for Secure Socket Layer (SSL) communications via the QSslSocket class.
|
|
140 |
\o Support for XML Localization Interchange File Format (XLIFF) files in \QL.
|
|
141 |
\o A new font subsystem for Qt for Embedded Linux.
|
|
142 |
\endlist
|
|
143 |
|
|
144 |
In Qt 4.2:
|
|
145 |
\list
|
|
146 |
\o The \l{Graphics View} framework for producing interactive graphics.
|
|
147 |
\o \l{Desktop Integration}{Desktop integration} facilities for applications.
|
|
148 |
\o \l{Qt Style Sheets} enable easy, yet powerful customization of
|
|
149 |
user interfaces.
|
|
150 |
\o Support for the \l{intro-to-dbus.html}{D-Bus} Inter-Process Communication (IPC) and Remote Procedure Calling (RPC) mechanism.
|
|
151 |
\o An \l{Undo Framework}{Undo framework} based on the
|
|
152 |
\l{Books about GUI Design#Design Patterns}{Command pattern}.
|
|
153 |
\o Support for model-based \l{QCompleter}{text completion} in standard and
|
|
154 |
custom widgets.
|
|
155 |
\o New widgets and GUI features, such as QCalendarWidget and
|
|
156 |
QGLFramebufferObject.
|
|
157 |
\o Classes to provide higher level application infrastructure, such as
|
|
158 |
QFileSystemWatcher and QDataWidgetMapper.
|
|
159 |
\endlist
|
|
160 |
|
|
161 |
In Qt 4.1:
|
|
162 |
\list
|
|
163 |
\o Integrated support for rendering
|
|
164 |
\l{The Arthur Paint System#SVG Rendering Support}{Scalable Vector Graphics}
|
|
165 |
(SVG) drawings and animations.
|
|
166 |
\o Support for
|
|
167 |
\l{QWidget#Transparency and Double Buffering}{child widget transparency}
|
|
168 |
on all platforms.
|
|
169 |
\o A Portable Document Format (PDF) backend for Qt's printing system.
|
|
170 |
\o A \l{QTestLib Manual}{unit testing framework} for Qt applications and
|
|
171 |
libraries.
|
|
172 |
\o Modules for \l{QtDesigner}{extending \QD} and
|
|
173 |
\l{QtUiTools}{dynamic user interface building}.
|
|
174 |
\o New \l{Proxy Models}{proxy models} to enable view-specific sorting and
|
|
175 |
filtering of data displayed using item views.
|
|
176 |
\o Support for \l{Installing Qt on Mac OS X}{universal binaries} on Mac OS X.
|
|
177 |
\o Additional features for developers using \l{QtOpenGL}{OpenGL}, such as
|
|
178 |
support for pixel and sample buffers.
|
|
179 |
\o A flexible \l{QSyntaxHighlighter}{syntax highlighting class} based on the
|
|
180 |
\l{Scribe} rich text framework.
|
|
181 |
\o Support for \l{QNetworkProxy}{network proxy} servers using the SOCKS5
|
|
182 |
protocol.
|
|
183 |
\o Support for OLE verbs and MIME data handling in \l{ActiveQt}.
|
|
184 |
\endlist
|
|
185 |
|
|
186 |
For more information about improvements in each Qt release, see
|
|
187 |
the \l{http://qt.nokia.com/developer/changes/}
|
|
188 |
{detailed lists of changes}.
|
|
189 |
|
|
190 |
\section1 Significant Improvements
|
|
191 |
|
|
192 |
The following modules have been significantly improved for Qt 4:
|
|
193 |
|
|
194 |
\list
|
|
195 |
\o A fully cross-platform \l{accessibility}
|
|
196 |
module, with support for the emerging SP-API Unix standard in
|
|
197 |
addition to Microsoft and Mac Accessibility.
|
|
198 |
\o The \l{qt4-sql.html}{SQL module}, which is now based on the
|
|
199 |
Interview model/view framework.
|
|
200 |
\o The \l{qt4-network.html}{network module}, with better support
|
|
201 |
for UDP and synchronous sockets.
|
|
202 |
\o The \l{qt4-styles.html}{style API}, which is now decoupled from
|
|
203 |
the widgets, meaning that you can draw any user interface element on
|
|
204 |
any device (widget, pixmap, etc.).
|
|
205 |
\o Enhanced \l{qt4-threads.html}{thread support}, with signal-slot
|
|
206 |
connections across threads and per-thread event loops.
|
|
207 |
\o A new \l{resource system} for embedding images
|
|
208 |
and other resource files into the application executable.
|
|
209 |
\endlist
|
|
210 |
|
|
211 |
\section1 Build System
|
|
212 |
|
|
213 |
Unlike previous Qt releases, Qt 4 is a collection of smaller
|
|
214 |
libraries:
|
|
215 |
|
|
216 |
\table
|
|
217 |
\header \o Library \o Description
|
|
218 |
\row \o \l{QtCore} \o Core non-GUI functionality
|
|
219 |
\row \o \l{QtGui} \o Core GUI functionality
|
|
220 |
\row \o \l{QtNetwork} \o Network module
|
|
221 |
\row \o \l{QtOpenGL} \o OpenGL module
|
|
222 |
\row \o \l{QtSql} \o SQL module
|
|
223 |
\row \o \l{QtSvg} \o SVG rendering classes
|
|
224 |
\row \o \l{QtXml} \o XML module
|
|
225 |
\row \o \l{Qt3Support} \o Qt 3 support classes
|
|
226 |
\row \o \l{QAxContainer} \o ActiveQt client extension
|
|
227 |
\row \o \l{QAxServer} \o ActiveQt server extension
|
|
228 |
\row \o \l{QtAssistant} \o Classes for launching Qt Assistant
|
|
229 |
\row \o \l{QtDesigner} \o Classes for extending and embedding Qt Designer
|
|
230 |
\row \o \l{QtUiTools} \o Classes for dynamic GUI generation
|
|
231 |
\row \o \l{QtTest} \o Tool classes for unit testing
|
|
232 |
\endtable
|
|
233 |
|
|
234 |
QtCore contains tool classes like QString, QList, and QFile, as
|
|
235 |
well as kernel classes like QObject and QTimer. The QApplication
|
|
236 |
class has been refactored so that it can be used in non-GUI
|
|
237 |
applications. It is split into QCoreApplication (in \l QtCore)
|
|
238 |
and QApplication (in \l QtGui).
|
|
239 |
|
|
240 |
This split makes it possible to develop server applications using Qt
|
|
241 |
without linking in any unnecessary GUI-related code and without
|
|
242 |
requiring GUI-related system libraries to be present on the target
|
|
243 |
machine (e.g. Xlib on X11, Carbon on Mac OS X).
|
|
244 |
|
|
245 |
If you use qmake to generate your makefiles, qmake will by default
|
|
246 |
link your application against QtCore and QtGui. To remove the
|
|
247 |
dependency upon QtGui, add the line
|
|
248 |
|
|
249 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 0
|
|
250 |
|
|
251 |
to your .pro file. To enable the other libraries, add the line
|
|
252 |
|
|
253 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 1
|
|
254 |
|
|
255 |
Another change to the build system is that moc now understands
|
|
256 |
preprocessor directives. qmake automatically passes the defines set
|
|
257 |
for your project (using "DEFINES +=") on to moc, which has its own
|
|
258 |
built-in C++ preprocessor.
|
|
259 |
|
|
260 |
To compile code that uses UI files, you will also need this line in
|
|
261 |
the .pro file:
|
|
262 |
|
|
263 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 2
|
|
264 |
|
|
265 |
\section1 Include Syntax
|
|
266 |
|
|
267 |
The syntax for including Qt class definitions has become
|
|
268 |
|
|
269 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 3
|
|
270 |
|
|
271 |
For example:
|
|
272 |
|
|
273 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 4
|
|
274 |
|
|
275 |
This is guaranteed to work for any public Qt class. The old syntax,
|
|
276 |
|
|
277 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 5
|
|
278 |
|
|
279 |
still works, but we encourage you to switch to the new syntax.
|
|
280 |
|
|
281 |
If you attempt to include a header file from a library that isn't
|
|
282 |
linked against the application, this will result in a
|
|
283 |
compile-time warning (e.g., "QSqlQuery: No such file or
|
|
284 |
directory"). You can remedy to this problem either by removing
|
|
285 |
the offending include or by specifying the missing library in the
|
|
286 |
QT entry of your \c .pro file (see \l{Build System} above).
|
|
287 |
|
|
288 |
To include the definitions for all the classes in a library, simply
|
|
289 |
specify the name of that library. For example:
|
|
290 |
|
|
291 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 6
|
|
292 |
|
|
293 |
\section1 Namespaces
|
|
294 |
|
|
295 |
Qt 2 introduced a class called Qt for global-like constants
|
|
296 |
(e.g., \c{Qt::yellow}). The C++ namespace construct was not used
|
|
297 |
because not all compilers understood it when it was released.
|
|
298 |
|
|
299 |
With Qt 4, the Qt class has become the Qt namespace. If you want
|
|
300 |
to access a constant that is part of the Qt namespace, prefix it
|
|
301 |
with \c Qt:: (e.g., \c{Qt::yellow}), or add the directive
|
|
302 |
|
|
303 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 7
|
|
304 |
|
|
305 |
at the top of your source files, after your \c #include
|
|
306 |
directives. If you use the \c{using namespace} syntax you don't
|
|
307 |
need the prefix (e.g., \c yellow is sufficient).
|
|
308 |
|
|
309 |
When porting Qt 3 applications, you may run into some source
|
|
310 |
compatibility problems with some of these symbols. For example,
|
|
311 |
in Qt 3, it was legal to write \c QWidget::yellow instead of \c
|
|
312 |
Qt::yellow, because QWidget inherited from Qt. This won't work in
|
|
313 |
Qt 4; you must write \c Qt::yellow or add the "using namespace"
|
|
314 |
directive and drop the \c Qt:: prefix.
|
|
315 |
|
|
316 |
The \l{qt3to4 - The Qt 3 to 4 Porting Tool}{qt3to4} porting tool
|
|
317 |
automates this conversion.
|
|
318 |
|
|
319 |
\section1 QObject/QWidget Constructors
|
|
320 |
|
|
321 |
In Qt 4 we have tried to simplify the constructors of QObject/QWidget
|
|
322 |
subclasses. This makes subclassing easier, at the same time as it
|
|
323 |
helps make the Qt library more efficient.
|
|
324 |
|
|
325 |
Constructors no longer take a "const char *name" parameter. If
|
|
326 |
you want to specify a name for a QObject, you must call
|
|
327 |
QObject::setObjectName() after construction. The object name is
|
|
328 |
now a QString. The reasons for this change are:
|
|
329 |
|
|
330 |
\list
|
|
331 |
\o Code that used it looked confusing, for example:
|
|
332 |
|
|
333 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 8
|
|
334 |
|
|
335 |
\c label1 is a QLabel that displays the text "Hello"; \c
|
|
336 |
label2 is a QLabel with no text, with the object name
|
|
337 |
"Hello".
|
|
338 |
|
|
339 |
\o From surveys we did, most users didn't use the name, although
|
|
340 |
they blindly followed Qt's convention and provided a "const
|
|
341 |
char *name" in their subclasses's constructors. For example:
|
|
342 |
|
|
343 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 9
|
|
344 |
|
|
345 |
\o The name parameter was in Qt since version 1, and it always
|
|
346 |
was documented as: "It is not very useful in the current
|
|
347 |
version of Qt, but it will become increasingly important in
|
|
348 |
the future." Ten years later, it still hasn't fulfilled its
|
|
349 |
promise.
|
|
350 |
\endlist
|
|
351 |
|
|
352 |
QWidget's \c WFlags data type has been split in two:
|
|
353 |
Qt::WindowFlags specifies low-level window flags (the type of
|
|
354 |
window and the frame style), whereas Qt::WidgetAttribute
|
|
355 |
specifies various higher-level attributes about the widget (e.g.,
|
|
356 |
WA_StaticContents). Widget attributes can be set at any time
|
|
357 |
using QWidget::setAttribute(); low-level window flags can be
|
|
358 |
passed to the QWidget constructor or set later using
|
|
359 |
QWidget::setParent(). As a consequence, the constructors of most
|
|
360 |
QWidget subclasses don't need to provide a \c WFlags parameter.
|
|
361 |
|
|
362 |
The \e parent parameter of all QObject classes in Qt defaults to
|
|
363 |
a 0 pointer, as it used to do in Qt 1. This enables a style of
|
|
364 |
programming where widgets are created without parents and then
|
|
365 |
inserted in a layout, at which point the layout automatically
|
|
366 |
reparents them.
|
|
367 |
|
|
368 |
\section1 Dynamic Casts
|
|
369 |
|
|
370 |
Qt 4 provides a qobject_cast<>() function that performs a dynamic cast
|
|
371 |
based on the meta-information generated by moc for QObject
|
|
372 |
subclasses. Unlike the standard C++ dynamic_cast<>() construct,
|
|
373 |
qobject_cast<>() works even when RTTI is disabled, and it works correctly
|
|
374 |
across DLL boundaries.
|
|
375 |
|
|
376 |
Here's the Qt 3 idiom to cast a type to a subtype:
|
|
377 |
|
|
378 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 10
|
|
379 |
|
|
380 |
The Qt 4 idiom is both cleaner and safer, because typos will always
|
|
381 |
result in compiler errors:
|
|
382 |
|
|
383 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 11
|
|
384 |
|
|
385 |
\section1 QPointer<T>
|
|
386 |
|
|
387 |
The QPointer<T> class provides a pointer to type T (where T inherits
|
|
388 |
from QObject) that is automatically set to 0 when the referenced
|
|
389 |
object is destroyed. Guarded pointers are useful whenever you want to
|
|
390 |
store a pointer to an object you do not own.
|
|
391 |
|
|
392 |
Example:
|
|
393 |
|
|
394 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 12
|
|
395 |
|
|
396 |
QPointer<T> is more or less the same as the old QGuardedPtr<T> class,
|
|
397 |
except that it is now implemented in a much more lightweight manner
|
|
398 |
than before. The cost of one QPointer<T> object is now approximately
|
|
399 |
the same as that of a signal--slot connection.
|
|
400 |
|
|
401 |
\section1 Paint Events
|
|
402 |
|
|
403 |
Qt 4 supports double buffering transparently on all platforms. This
|
|
404 |
feature can be turned off on a per-widget basis by calling
|
|
405 |
QWidget::setAttribute(Qt::WA_PaintOnScreen).
|
|
406 |
|
|
407 |
A consequence of this is that all painting must now be done from the
|
|
408 |
paintEvent() function. This is also required by the HIView API on Mac
|
|
409 |
OS X. In practice, this is seldom a problem, since you can call
|
|
410 |
update() from anywhere in your code to create a paint event, with the
|
|
411 |
region to update as the argument.
|
|
412 |
|
|
413 |
To help porting, QWidget supports a Qt::WA_PaintOutsidePaintEvent
|
|
414 |
attribute that can be set to make it possible to paint outside
|
|
415 |
\l{QWidget::paintEvent()}{paintEvent()} on Windows and X11.
|
|
416 |
|
|
417 |
\section1 Qt 3 Support Layer
|
|
418 |
|
|
419 |
Qt 4 provides an extension library that applications based on Qt 3,
|
|
420 |
called Qt3Support, that Qt applications can link against. This allows
|
|
421 |
for more compatibility than ever before, without bloating Qt.
|
|
422 |
|
|
423 |
\list
|
|
424 |
\o Classes that have been replaced by a different class with the
|
|
425 |
same name, such as QListView, and classes that no longer exist in Qt 4
|
|
426 |
are available with a \c 3 in their name (e.g., Q3ListView, Q3Accel).
|
|
427 |
|
|
428 |
\o Other classes provide compatibility functions. Most of these are
|
|
429 |
implemented inline, so that they don't bloat the Qt libraries.
|
|
430 |
\endlist
|
|
431 |
|
|
432 |
To enable the Qt 3 support classes and functions, add the line
|
|
433 |
|
|
434 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 13
|
|
435 |
|
|
436 |
to your \c .pro file.
|
|
437 |
|
|
438 |
On Visual C++ 7 and GCC 3.2+, using compatibility functions often results
|
|
439 |
in a compiler warning (e.g., "'find' is deprecated"). If you want to turn
|
|
440 |
off that warning, add the line
|
|
441 |
|
|
442 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 14
|
|
443 |
|
|
444 |
to your \c .pro file.
|
|
445 |
|
|
446 |
If you want to use compatibility functions but don't want to link
|
|
447 |
against the Qt3Support library, add the line
|
|
448 |
|
|
449 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 15
|
|
450 |
|
|
451 |
or
|
|
452 |
|
|
453 |
\snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 16
|
|
454 |
|
|
455 |
to your \c .pro file, depending on whether you want compatibility
|
|
456 |
function calls to generate compiler warnings or not.
|
|
457 |
*/
|
|
458 |
|
|
459 |
/*!
|
|
460 |
\page qt4-6-intro.html
|
|
461 |
\title What's New in Qt 4.6
|
|
462 |
|
|
463 |
Qt 4.6 provides many improvements and enhancements over the
|
|
464 |
previous releases in the Qt 4 series. This document covers the
|
|
465 |
most important features in this release, separated by category.
|
|
466 |
|
|
467 |
\omit
|
|
468 |
A comprehensive list of changes between Qt 4.5 and Qt 4.6 is
|
|
469 |
included in the \c changes-4.6.0 file
|
|
470 |
\l{http://qt.nokia.com/developer/changes/changes-4.6.0}{available
|
|
471 |
online}. A \l{Known Issues in %VERSION%}{list of known issues}
|
|
472 |
for this release is also available.
|
|
473 |
|
|
474 |
Changes between this release and the previous release are provided
|
|
475 |
in the \c{changes-%VERSION%} file (also
|
|
476 |
\l{http://qt.nokia.com/developer/changes/changes-%VERSION%}{available online}).
|
|
477 |
\endomit
|
|
478 |
|
|
479 |
A list of other Qt 4 features can be found on the \bold{\l{What's
|
|
480 |
New in Qt 4}} page.
|
|
481 |
|
|
482 |
\bold{Highlights}
|
|
483 |
|
|
484 |
\tableofcontents
|
|
485 |
|
|
486 |
\section1 Support for Symbian
|
|
487 |
|
|
488 |
Qt 4.6 is the first release to include support for the Symbian
|
|
489 |
platform, with integration into the S60 framework. The port to
|
|
490 |
Symbian and S60 provides all functionality required to develop
|
|
491 |
rich end-user applications for devices running S60 3.1 and
|
|
492 |
later.
|
|
493 |
|
|
494 |
\section1 Animation Framework
|
|
495 |
|
|
496 |
The animation framework helps build highly animated,
|
|
497 |
high-performance GUIs without the hassle of managing complex
|
|
498 |
structures, timers, and easing curves, not to mention the large
|
|
499 |
state graphs that all animated GUIs tend to be full of.
|
|
500 |
|
|
501 |
The framework makes it easy to animate \l{QObject}s, including
|
|
502 |
QWidgets, by allowing Qt properties to be animated. It also allows
|
|
503 |
creating custom animations and interpolation functions. Graphics
|
|
504 |
views are not left out; one can animate \l{QGraphicsWidget}s and
|
|
505 |
new \l{QGraphicsObject}s which inherit from QGraphicsItem
|
|
506 |
(and thereby enable properties).
|
|
507 |
|
|
508 |
Animations are controlled using easing curves and can be grouped
|
|
509 |
together. This enables animations of arbitrary complexity.
|
|
510 |
|
|
511 |
The API is easy to grasp with functions such as start(), stop(),
|
|
512 |
pause(), and currentTime(). Here is an image from one of the
|
|
513 |
examples that come with the framework:
|
|
514 |
|
|
515 |
\image whatsnewanimatedtiles.png
|
|
516 |
|
|
517 |
The animation framework also plugs into the new Qt Statemachine by
|
|
518 |
allowing an animation to be played when transitions are triggered.
|
|
519 |
The state machine framework is introduced in 4.6 and is described
|
|
520 |
below.
|
|
521 |
|
|
522 |
See \l{The Animation Framework} documentation for more information.
|
|
523 |
|
|
524 |
\section1 State Machine Framework
|
|
525 |
|
|
526 |
The state machine framework provides a robust state chart
|
|
527 |
implementation based on Harel statecharts and SCXML. Qt's API lets
|
|
528 |
you construct such state graphs and execute them. The key benefits
|
|
529 |
of a state machine are:
|
|
530 |
|
|
531 |
\list
|
|
532 |
\o Simplify complex application semantics.
|
|
533 |
\o Use of states to reduce code bloat.
|
|
534 |
\o Use states to improve maintainability.
|
|
535 |
\o Makes event-driven programming robust and more
|
|
536 |
reusable.
|
|
537 |
\endlist
|
|
538 |
|
|
539 |
It is especially the last item here that makes using a state
|
|
540 |
machine worthwhile. A key characteristic of event-driven systems
|
|
541 |
(such as Qt applications) is that behavior often depends not only
|
|
542 |
on the last or current event, but also the events that preceded
|
|
543 |
it. With statecharts, this information is easy to express.
|
|
544 |
|
|
545 |
The framework fits neatly into Qt by allowing transitions to
|
|
546 |
trigger on signals and \l{QEvent}s. By inserting animations into
|
|
547 |
the state machine, it is also easier to use the framework for
|
|
548 |
animating GUIs, for instance.
|
|
549 |
|
|
550 |
See \l{The State Machine Framework} documentation for more infromation.
|
|
551 |
|
|
552 |
\section1 Multi-Touch and Gestures
|
|
553 |
|
|
554 |
Support for multi-touch input enables users to interact with many
|
|
555 |
parts of a user interface at the same time, and provides the basis
|
|
556 |
for gestures. Additional infrastructure for gesture recognition
|
|
557 |
allows a sequence of touch inputs to be combined to create gestures
|
|
558 |
that can be used to activate features and trigger actions in an
|
|
559 |
application.
|
|
560 |
|
|
561 |
\image gestures.png
|
|
562 |
|
|
563 |
This new functionality brings a number of benefits:
|
|
564 |
|
|
565 |
\list
|
|
566 |
\o Allows users to interact with applications in more natural ways.
|
|
567 |
\o Simplifies finger-based interaction with UI components.
|
|
568 |
\o Combines support for common basic gestures and multi-touch gestures
|
|
569 |
in a single general framework.
|
|
570 |
\o Enables extensibility by design.
|
|
571 |
\endlist
|
|
572 |
|
|
573 |
See the QTouchEvent class documentation for more information on multi-touch
|
|
574 |
input and QGestureEvent for gestures.
|
|
575 |
|
|
576 |
\section1 DOM access API
|
|
577 |
|
|
578 |
Web pages and XML both have very complex document object models.
|
|
579 |
The W3C selector API provides a very simple way to access and
|
|
580 |
manipulate such structures. This API makes it intuitive to access
|
|
581 |
DOM, helps reuse CSS selector knowledge, and gives little
|
|
582 |
maintenance or footprint overhead.
|
|
583 |
|
|
584 |
\code
|
|
585 |
QWebElement document = frame->documentElement();
|
|
586 |
QList<QWebElement> allSpans = document.findAll("span");
|
|
587 |
QList<QWebElement> introSpans = document.findAll("p.intro span");
|
|
588 |
\endcode
|
|
589 |
|
|
590 |
See the QWebElement class documentation for more information.
|
|
591 |
|
|
592 |
\section1 Performance Optimizations
|
|
593 |
|
|
594 |
As always, Qt continuously strive to optimize its performance.
|
|
595 |
For this release, we have:
|
|
596 |
|
|
597 |
\list
|
|
598 |
\o Rewritten the QGraphicsView rendering algorithm.
|
|
599 |
\o Made QPixmapCache support efficient Key datastructure.
|
|
600 |
\o Reduced overhead in QNetworkAccessManager.
|
|
601 |
\o Added the QContiguousCache class, which provides efficient caching of
|
|
602 |
contiguous data.
|
|
603 |
\o Added support for hardware-accelerated rendering through
|
|
604 |
\l{OpenVG Rendering in Qt}{OpenVG}
|
|
605 |
\o Removed Win9x support.
|
|
606 |
\endlist
|
|
607 |
|
|
608 |
\section1 Graphics Effects
|
|
609 |
|
|
610 |
Effects can be used to alter the appearance of UI elements such as
|
|
611 |
\l{QGraphicsItem}s and \l{QWidget}s. A range of standard effects such
|
|
612 |
as blurring, colorizing or blooming is provided, and it is possible to
|
|
613 |
implement custom effects.
|
|
614 |
|
|
615 |
\table
|
|
616 |
\row
|
|
617 |
\o
|
|
618 |
\o \img graphicseffect-plain.png
|
|
619 |
\o
|
|
620 |
\row
|
|
621 |
\o \img graphicseffect-blur.png
|
|
622 |
\o \img graphicseffect-colorize.png
|
|
623 |
\o \img graphicseffect-bloom.png
|
|
624 |
\endtable
|
|
625 |
|
|
626 |
See the QGraphicsEffect class documentation for more information.
|
|
627 |
|
|
628 |
\section1 XML Schema Validation
|
|
629 |
|
|
630 |
The QtXmlPatterns module can now be used to validate schemas, either
|
|
631 |
through C++ APIs in the Qt application, or using the xmlpatternsvalidator
|
|
632 |
command line utility. The implementation of XML Schema Validation supports
|
|
633 |
the specification version 1.0 in large parts.
|
|
634 |
|
|
635 |
\img xml-schema.png
|
|
636 |
|
|
637 |
See the \l{XML Processing} and QXmlSchema class documentation for more
|
|
638 |
information.
|
|
639 |
|
|
640 |
\section1 Qt3D enablers
|
|
641 |
|
|
642 |
As more of Qt, and more of the applications built on Qt go 3D,
|
|
643 |
API's should be provided to simplify this. Mainly, the new API
|
|
644 |
aims to make it more easy to create 3D applications with OpenGL.
|
|
645 |
It will also unify the Qt OpenGL codebase, and enable
|
|
646 |
cross-platform 3D codebase.
|
|
647 |
|
|
648 |
The main features of the Qt3D enablers are currently: Math
|
|
649 |
primitives for matrix multiplication, vectors, quaternions
|
|
650 |
(client-side), and API for vertex and fragment shaders, GLSL/ES.
|
|
651 |
Future research will, among other things include stencils,
|
|
652 |
scissors, vertex buffers and arrays, texture manipulation, and
|
|
653 |
geometry shaders.
|
|
654 |
|
|
655 |
\section1 Multimedia Services
|
|
656 |
|
|
657 |
Qt 4.6 comes with new classes for handling audio. These classes
|
|
658 |
provide low-level access to the system's audio system. By
|
|
659 |
specifying the audio format (QAudioFormat) and supplying audio
|
|
660 |
data through a QIODevice, you get direct access to the
|
|
661 |
functionality of the sound device. The API also comes with
|
|
662 |
functions to query audio devices for which audio formats they
|
|
663 |
support.
|
|
664 |
|
|
665 |
See the \l{QtMultimedia Module} documentation for more information.
|
|
666 |
|
|
667 |
\section1 New Classes, Functions, Macros, etc
|
|
668 |
|
|
669 |
Links to new classes, functions, macros, and other items
|
|
670 |
introduced in Qt 4.6.
|
|
671 |
|
|
672 |
\sincelist 4.6
|
|
673 |
|
|
674 |
*/
|
|
675 |
|
|
676 |
/*
|
|
677 |
\page qt4-5-intro.html
|
|
678 |
\title What's New in Qt 4.5
|
|
679 |
|
|
680 |
Qt 4.5 provides many improvements and enhancements over the previous releases
|
|
681 |
in the Qt 4 series. This document covers the most important features in this
|
|
682 |
release, separated by category.
|
|
683 |
|
|
684 |
A comprehensive list of changes between Qt 4.4 and Qt 4.5 is included
|
|
685 |
in the \c changes-4.5.0 file
|
|
686 |
\l{http://qt.nokia.com/developer/changes/changes-4.5.0}{available online}.
|
|
687 |
A \l{Known Issues in %VERSION%}{list of known issues} for this release is also
|
|
688 |
available.
|
|
689 |
|
|
690 |
Changes between this release and the previous release are provided
|
|
691 |
in the \c{changes-%VERSION%} file (also
|
|
692 |
\l{http://qt.nokia.com/developer/changes/changes-%VERSION%}{available online}).
|
|
693 |
|
|
694 |
A list of other Qt 4 features can be found on the
|
|
695 |
\bold{\l{What's New in Qt 4}} page.
|
|
696 |
|
|
697 |
\bold{Highlights}
|
|
698 |
|
|
699 |
\tableofcontents
|
|
700 |
|
|
701 |
\section1 Qt WebKit Integration
|
|
702 |
|
|
703 |
\image webkit-netscape-plugin.png
|
|
704 |
|
|
705 |
The WebKit browser engine included with Qt has been upgraded to the latest
|
|
706 |
upstream (trunk) version of WebKit, bringing the latest features and
|
|
707 |
improvements to Qt applications. These include:
|
|
708 |
|
|
709 |
\list
|
|
710 |
\o Support for full page zooming, with appropriate rescaling of images and fonts.
|
|
711 |
\o The CSS-based transformation and animation features provided by a WebKit
|
|
712 |
extension.
|
|
713 |
\o Performance improvements due to faster JavaScript engine and optimized
|
|
714 |
page loading.
|
|
715 |
\endlist
|
|
716 |
|
|
717 |
Standards compatibility improvements include provision for the Netscape plugin
|
|
718 |
API, allowing most Netscape plugins to be used in-process, support for HTML 5
|
|
719 |
audio and video elements using Qt's Phonon integration, and
|
|
720 |
\l{Web Application Support}{facilities for client-side storage of Web content}.
|
|
721 |
|
|
722 |
\section1 Performance Improvements
|
|
723 |
|
|
724 |
The introduction of the QtBenchLib performance benchmarking library enables
|
|
725 |
performance benchmarking and regression testing. Core parts of Qt itself have
|
|
726 |
undergone focused re-engineering for improved graphics performance, including
|
|
727 |
paint engine and text rendering improvements, Graphics View and style sheet
|
|
728 |
performance improvements.
|
|
729 |
|
|
730 |
The X11 paint engine now uses XSHM (the X shared memory extension), resulting
|
|
731 |
in reduced overhead for painting operations.
|
|
732 |
|
|
733 |
A new OpenGL ES 2.0-based paint engine complements the existing OpenGL paint
|
|
734 |
engine, but with a focus on embedded devices.
|
|
735 |
|
|
736 |
Qt now features a pluggable graphics system, making it possible for users
|
|
737 |
and developers to select raster, OpenGL or native graphics systems to take
|
|
738 |
into account the specific needs of their applications and get the best
|
|
739 |
performance out of them.
|
|
740 |
|
|
741 |
\section1 Mac OS X Cocoa Support
|
|
742 |
|
|
743 |
\image mac-cocoa.png
|
|
744 |
|
|
745 |
Qt for Mac OS X has been substantially rewritten to use Apple's Cocoa API,
|
|
746 |
enabling Qt applications to be deployed on 64-bit Macintosh hardware.
|
|
747 |
In addition, the new QMacCocoaViewContainer and QMacNativeWidget classes
|
|
748 |
provide integration with Cocoa's own features and controls.
|
|
749 |
|
|
750 |
For many applications, a simple recompilation is all that is required
|
|
751 |
to produce an executable for 64-bit systems. Applications that use
|
|
752 |
specific features may require a few changes first.
|
|
753 |
|
|
754 |
\section1 Windows CE Feature Parity
|
|
755 |
|
|
756 |
Qt for Windows CE has been updated to bring features of Qt 4.4 and Qt 4.5
|
|
757 |
to the Windows CE platform, including:
|
|
758 |
|
|
759 |
\list
|
|
760 |
\o Phonon Multimedia Framework, using a Direct-Show based backend for audio
|
|
761 |
and video playback and a Simple WaveOut backend for devices without DirectShow.
|
|
762 |
\o The inclusion of Qt WebKit integration features previously unavailable for
|
|
763 |
Qt 4.4 on Windows CE.
|
|
764 |
\endlist
|
|
765 |
|
|
766 |
Support on all Windows CE platforms; recommended for WinCE 6 and higher.
|
|
767 |
|
|
768 |
The inclusion of these features enables developers to easily integrate Web and
|
|
769 |
multimedia content into Qt applications on Windows CE Standard Edition while
|
|
770 |
retaining full cross-platform compatibility with other Qt platforms.
|
|
771 |
|
|
772 |
\section1 XML Transformations with XSLT
|
|
773 |
|
|
774 |
The QtXmlPatterns module has been extended to cover XSLT, a transformation language
|
|
775 |
for XML documents. A common application of this is the transformation of XML data
|
|
776 |
into human-readable formats for reporting purposes.
|
|
777 |
|
|
778 |
XSLT makes it simple to reformat XML content without changing data structures,
|
|
779 |
removes the need for an intermediate DOM layer for presentation, and enables
|
|
780 |
rapid solutions to be created; for example, creating reports as HTML or PDF.
|
|
781 |
|
|
782 |
\section1 Qt Script Debugger
|
|
783 |
|
|
784 |
\image qtscript-debugger-small.png
|
|
785 |
|
|
786 |
Developers using Qt Script in their applications can take advantage of
|
|
787 |
the new \l{Qt Script Debugger Manual}{Qt Script Debugger} to provide
|
|
788 |
error reporting for scripts, and to let users track down bugs in their
|
|
789 |
own scripts.
|
|
790 |
|
|
791 |
Many standard features of GUI debugging tools are present, allowing the
|
|
792 |
developer to step through running script code, inspect variables,
|
|
793 |
automatically catch exceptions, and set conditional breakpoints.
|
|
794 |
|
|
795 |
\section1 OpenDocument File Format Support
|
|
796 |
|
|
797 |
Qt 4.5 includes support for writing rich text documents as OpenDocument files via
|
|
798 |
the newly-introduced QTextDocumentWriter class. This provides an generic mechanism
|
|
799 |
for file export that can be used to introduce support for additional formats in
|
|
800 |
future releases.
|
|
801 |
|
|
802 |
\section1 Improved Network Proxy Support
|
|
803 |
|
|
804 |
Qt's networking classes have been updated with
|
|
805 |
\l{QtNetwork Module#Support for Network Proxies}{improved proxy support}.
|
|
806 |
This includes improved integration with system proxy settings and the added
|
|
807 |
ability to handle non-trivial proxy cases.
|
|
808 |
|
|
809 |
\section1 Qt Designer Improvements
|
|
810 |
|
|
811 |
\image designer-screenshot-small.png
|
|
812 |
|
|
813 |
Qt Designer 4.5 boasts some improvements on usability, for example:
|
|
814 |
|
|
815 |
\list
|
|
816 |
\o \bold{Icon Mode} for the widget box which substantially reduces
|
|
817 |
scrolling.
|
|
818 |
\o \bold{Morphing Widgets} which lets you morph similar widget types,
|
|
819 |
e.g., a QWidget to a QFrame, types via the context menu's
|
|
820 |
\e{Morph into} entry.
|
|
821 |
\o \bold{Filters} for the \gui{Property Editor} that lets you find
|
|
822 |
properties or widgets quickly.
|
|
823 |
\o \bold{Find option} for the \gui{Object Inspector} that performs an
|
|
824 |
incremental search on the form's widgets. Also, the objects' layout
|
|
825 |
state is displayed here with using an icon on the left. Broken
|
|
826 |
layouts are represented with the same icon used for the
|
|
827 |
\e{Break Layout} action.
|
|
828 |
\endlist
|
|
829 |
|
|
830 |
In addition, Qt Designer now features an \gui{Embedded Design} tab that can
|
|
831 |
be found in the \gui Preferences dialog. Within this tab, you can define
|
|
832 |
embedded device profiles. These profiles contains screen settings, e.g.,
|
|
833 |
display resolution, default font and default style. Qt Designer will use
|
|
834 |
these settings when you edit forms.
|
|
835 |
|
|
836 |
More information about these improvements can be found in the
|
|
837 |
\l{What's New in Qt Designer 4.5} overview.
|
|
838 |
|
|
839 |
\section1 Qt Linguist Improvements
|
|
840 |
|
|
841 |
Qt Linguist can now load and edit multiple translation files simultaneously.
|
|
842 |
|
|
843 |
Support for XML Localization Interchange File Format (XLIFF) files, previously added
|
|
844 |
to the \c lupdate tool in Qt 4.3, has been improved and extended to the rest of the
|
|
845 |
Qt Linguist toolchain. This enables files stored in Qt's TS translation format to
|
|
846 |
be exported for use with other tools.
|
|
847 |
|
|
848 |
The GNU Gettext PO format, which is commonly used in Open Source projects,
|
|
849 |
is now supported by Qt Linguist.
|
|
850 |
|
|
851 |
Support for a new way to annotate messages, using comments in the source code,
|
|
852 |
has been added to the toolchain. See the QObject::tr() documentation for a detailed
|
|
853 |
description and examples.
|
|
854 |
|
|
855 |
The new \c lconvert filter tool facilitates conversion between file formats and
|
|
856 |
can be used to perform other transformations on collections of translatable strings.
|
|
857 |
|
|
858 |
\section1 Graphics Enhancements
|
|
859 |
|
|
860 |
In addition to the performance improvements in this release, a number of graphics
|
|
861 |
enhancements extend support for existing features to more platforms and expand Qt's
|
|
862 |
core set of features with successful add-ons.
|
|
863 |
|
|
864 |
Widget style sheets can now be used on Mac OS X, making this approach to theming
|
|
865 |
and styling viable for truly cross-platform applications.
|
|
866 |
|
|
867 |
Support for ARGB top-level widgets, previously available as a separate solution,
|
|
868 |
is now provided as an integral part of Qt. This makes it possible to create windows
|
|
869 |
with translucent regions on systems with the appropriate support from the user's
|
|
870 |
window system. See the \l{QWidget#Creating Translucent Windows}{Creating Translucent
|
|
871 |
Windows} section of the QWidget documentation for details of this feature.
|
|
872 |
|
|
873 |
|
|
874 |
\image gtk-style-screenshot.png
|
|
875 |
|
|
876 |
Improved GTK+ integration provided by the QGtkStyle class improves the look and feel
|
|
877 |
of Qt applications in GNOME and other GTK-based environments. The screenshot above
|
|
878 |
illustrates this clearly.
|
|
879 |
*/
|