1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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 4.6.1}{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-4.6.1} file (also
|
---|
476 | \l{http://qt.nokia.com/developer/changes/changes-4.6.1}{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 | See the \l{The Symbian platform - Introduction to Qt} for more information.
|
---|
495 |
|
---|
496 | \section1 Animation Framework
|
---|
497 |
|
---|
498 | The animation framework helps build highly animated,
|
---|
499 | high-performance GUIs without the hassle of managing complex
|
---|
500 | structures, timers, and easing curves, not to mention the large
|
---|
501 | state graphs that all animated GUIs tend to be full of.
|
---|
502 |
|
---|
503 | The framework makes it easy to animate \l{QObject}s, including
|
---|
504 | QWidgets, by allowing Qt properties to be animated. It also allows
|
---|
505 | creating custom animations and interpolation functions. Graphics
|
---|
506 | views are not left out; one can animate \l{QGraphicsWidget}s and
|
---|
507 | new \l{QGraphicsObject}s which inherit from QGraphicsItem
|
---|
508 | (and thereby enable properties).
|
---|
509 |
|
---|
510 | Animations are controlled using easing curves and can be grouped
|
---|
511 | together. This enables animations of arbitrary complexity.
|
---|
512 |
|
---|
513 | The API is easy to grasp with functions such as start(), stop(),
|
---|
514 | pause(), and currentTime(). Here is an image from one of the
|
---|
515 | examples that come with the framework:
|
---|
516 |
|
---|
517 | \image whatsnewanimatedtiles.png
|
---|
518 |
|
---|
519 | The animation framework also plugs into the new Qt Statemachine by
|
---|
520 | allowing an animation to be played when transitions are triggered.
|
---|
521 | The state machine framework is introduced in 4.6 and is described
|
---|
522 | below.
|
---|
523 |
|
---|
524 | See \l{The Animation Framework} documentation for more information.
|
---|
525 |
|
---|
526 | \section1 State Machine Framework
|
---|
527 |
|
---|
528 | The state machine framework provides a robust state chart
|
---|
529 | implementation based on Harel statecharts and SCXML. Qt's API lets
|
---|
530 | you construct such state graphs and execute them. The key benefits
|
---|
531 | of a state machine are:
|
---|
532 |
|
---|
533 | \list
|
---|
534 | \o Simplify complex application semantics.
|
---|
535 | \o Use of states to reduce code bloat.
|
---|
536 | \o Use states to improve maintainability.
|
---|
537 | \o Makes event-driven programming robust and more
|
---|
538 | reusable.
|
---|
539 | \endlist
|
---|
540 |
|
---|
541 | It is especially the last item here that makes using a state
|
---|
542 | machine worthwhile. A key characteristic of event-driven systems
|
---|
543 | (such as Qt applications) is that behavior often depends not only
|
---|
544 | on the last or current event, but also the events that preceded
|
---|
545 | it. With statecharts, this information is easy to express.
|
---|
546 |
|
---|
547 | The framework fits neatly into Qt by allowing transitions to
|
---|
548 | trigger on signals and \l{QEvent}s. By inserting animations into
|
---|
549 | the state machine, it is also easier to use the framework for
|
---|
550 | animating GUIs, for instance.
|
---|
551 |
|
---|
552 | See \l{The State Machine Framework} documentation for more information.
|
---|
553 |
|
---|
554 | \section1 Multi-Touch and Gestures
|
---|
555 |
|
---|
556 | Support for multi-touch input enables users to interact with many
|
---|
557 | parts of a user interface at the same time, and provides the basis
|
---|
558 | for gestures. Additional infrastructure for gesture recognition
|
---|
559 | allows a sequence of touch inputs to be combined to create gestures
|
---|
560 | that can be used to activate features and trigger actions in an
|
---|
561 | application.
|
---|
562 |
|
---|
563 | \image gestures.png
|
---|
564 |
|
---|
565 | This new functionality brings a number of benefits:
|
---|
566 |
|
---|
567 | \list
|
---|
568 | \o Allows users to interact with applications in more natural ways.
|
---|
569 | \o Simplifies finger-based interaction with UI components.
|
---|
570 | \o Combines support for common basic gestures and multi-touch gestures
|
---|
571 | in a single general framework.
|
---|
572 | \o Enables extensibility by design.
|
---|
573 | \endlist
|
---|
574 |
|
---|
575 | See the QTouchEvent class documentation for more information on multi-touch
|
---|
576 | input and QGestureEvent for gestures.
|
---|
577 |
|
---|
578 | \section1 DOM access API
|
---|
579 |
|
---|
580 | Web pages and XML both have very complex document object models.
|
---|
581 | The W3C selector API provides a very simple way to access and
|
---|
582 | manipulate such structures. This API makes it intuitive to access
|
---|
583 | DOM, helps reuse CSS selector knowledge, and gives little
|
---|
584 | maintenance or footprint overhead.
|
---|
585 |
|
---|
586 | \snippet webkitsnippets/webelement/main.cpp FindAll
|
---|
587 |
|
---|
588 | See the QWebElement class documentation for more information.
|
---|
589 |
|
---|
590 | \section1 Performance Optimizations
|
---|
591 |
|
---|
592 | As always, Qt continuously strive to optimize its performance.
|
---|
593 | For this release, we have:
|
---|
594 |
|
---|
595 | \list
|
---|
596 | \o Rewritten the QGraphicsView rendering algorithm.
|
---|
597 | \o Made QPixmapCache support efficient Key datastructure.
|
---|
598 | \o Reduced overhead in QNetworkAccessManager.
|
---|
599 | \o Added the QContiguousCache class, which provides efficient caching of
|
---|
600 | contiguous data.
|
---|
601 | \o Added support for hardware-accelerated rendering through
|
---|
602 | \l{OpenVG Rendering in Qt}{OpenVG}
|
---|
603 | \o Removed Win9x support.
|
---|
604 | \endlist
|
---|
605 |
|
---|
606 | \section1 Graphics Effects
|
---|
607 |
|
---|
608 | Effects can be used to alter the appearance of UI elements such as
|
---|
609 | \l{QGraphicsItem}s and \l{QWidget}s. A couple of standard effects such
|
---|
610 | as blurring, colorizing and drop shadow are provided, and it is
|
---|
611 | possible to implement custom effects.
|
---|
612 |
|
---|
613 | \table
|
---|
614 | \row
|
---|
615 | \o{2,1} \img graphicseffect-plain.png
|
---|
616 | \row
|
---|
617 | \o \img graphicseffect-blur.png
|
---|
618 | \o \img graphicseffect-colorize.png
|
---|
619 | \row
|
---|
620 | \o \img graphicseffect-opacity.png
|
---|
621 | \o \img graphicseffect-drop-shadow.png
|
---|
622 | \endtable
|
---|
623 |
|
---|
624 | See the QGraphicsEffect class documentation for more information.
|
---|
625 |
|
---|
626 | \section1 XML Schema Validation
|
---|
627 |
|
---|
628 | The QtXmlPatterns module can now be used to validate schemas, either
|
---|
629 | through C++ APIs in the Qt application, or using the xmlpatternsvalidator
|
---|
630 | command line utility. The implementation of XML Schema Validation supports
|
---|
631 | the specification version 1.0 in large parts.
|
---|
632 |
|
---|
633 | \img xml-schema.png
|
---|
634 |
|
---|
635 | See the \l{XML Processing} and QXmlSchema class documentation for more
|
---|
636 | information.
|
---|
637 |
|
---|
638 | \section1 Qt3D enablers
|
---|
639 |
|
---|
640 | As more of Qt, and more of the applications built on Qt go 3D,
|
---|
641 | API's should be provided to simplify this. Mainly, the new API
|
---|
642 | aims to make it more easy to create 3D applications with OpenGL.
|
---|
643 | It will also unify the Qt OpenGL codebase, and enable
|
---|
644 | cross-platform 3D codebase.
|
---|
645 |
|
---|
646 | The main features of the Qt3D enablers are currently: Math
|
---|
647 | primitives for matrix multiplication, vectors, quaternions
|
---|
648 | (client-side), and API for vertex and fragment shaders, GLSL/ES.
|
---|
649 | Future research will, among other things include stencils,
|
---|
650 | scissors, vertex buffers and arrays, texture manipulation, and
|
---|
651 | geometry shaders.
|
---|
652 |
|
---|
653 | \section1 Multimedia Services
|
---|
654 |
|
---|
655 | Qt 4.6 comes with new classes for handling audio. These classes
|
---|
656 | provide low-level access to the system's audio system. By
|
---|
657 | specifying the audio format (QAudioFormat) and supplying audio
|
---|
658 | data through a QIODevice, you get direct access to the
|
---|
659 | functionality of the sound device. The API also comes with
|
---|
660 | functions to query audio devices for which audio formats they
|
---|
661 | support.
|
---|
662 |
|
---|
663 | See the \l{QtMultimedia Module} documentation for more information.
|
---|
664 |
|
---|
665 | \section1 New Classes, Functions, Macros, etc.
|
---|
666 |
|
---|
667 | Links to new classes, functions, macros, and other items
|
---|
668 | introduced in Qt 4.6.
|
---|
669 |
|
---|
670 | \sincelist 4.6
|
---|
671 |
|
---|
672 | */
|
---|
673 |
|
---|
674 | /*
|
---|
675 | \page qt4-5-intro.html
|
---|
676 | \title What's New in Qt 4.5
|
---|
677 |
|
---|
678 | Qt 4.5 provides many improvements and enhancements over the previous releases
|
---|
679 | in the Qt 4 series. This document covers the most important features in this
|
---|
680 | release, separated by category.
|
---|
681 |
|
---|
682 | A comprehensive list of changes between Qt 4.4 and Qt 4.5 is included
|
---|
683 | in the \c changes-4.5.0 file
|
---|
684 | \l{http://qt.nokia.com/developer/changes/changes-4.5.0}{available online}.
|
---|
685 | A \l{Known Issues in 4.6.1}{list of known issues} for this release is also
|
---|
686 | available.
|
---|
687 |
|
---|
688 | Changes between this release and the previous release are provided
|
---|
689 | in the \c{changes-4.6.1} file (also
|
---|
690 | \l{http://qt.nokia.com/developer/changes/changes-4.6.1}{available online}).
|
---|
691 |
|
---|
692 | A list of other Qt 4 features can be found on the
|
---|
693 | \bold{\l{What's New in Qt 4}} page.
|
---|
694 |
|
---|
695 | \bold{Highlights}
|
---|
696 |
|
---|
697 | \tableofcontents
|
---|
698 |
|
---|
699 | \section1 Qt WebKit Integration
|
---|
700 |
|
---|
701 | \image webkit-netscape-plugin.png
|
---|
702 |
|
---|
703 | The WebKit browser engine included with Qt has been upgraded to the latest
|
---|
704 | upstream (trunk) version of WebKit, bringing the latest features and
|
---|
705 | improvements to Qt applications. These include:
|
---|
706 |
|
---|
707 | \list
|
---|
708 | \o Support for full page zooming, with appropriate rescaling of images and fonts.
|
---|
709 | \o The CSS-based transformation and animation features provided by a WebKit
|
---|
710 | extension.
|
---|
711 | \o Performance improvements due to faster JavaScript engine and optimized
|
---|
712 | page loading.
|
---|
713 | \endlist
|
---|
714 |
|
---|
715 | Standards compatibility improvements include provision for the Netscape plugin
|
---|
716 | API, allowing most Netscape plugins to be used in-process, support for HTML 5
|
---|
717 | audio and video elements using Qt's Phonon integration, and
|
---|
718 | \l{Web Application Support}{facilities for client-side storage of Web content}.
|
---|
719 |
|
---|
720 | \section1 Performance Improvements
|
---|
721 |
|
---|
722 | The introduction of the QtBenchLib performance benchmarking library enables
|
---|
723 | performance benchmarking and regression testing. Core parts of Qt itself have
|
---|
724 | undergone focused re-engineering for improved graphics performance, including
|
---|
725 | paint engine and text rendering improvements, Graphics View and style sheet
|
---|
726 | performance improvements.
|
---|
727 |
|
---|
728 | The X11 paint engine now uses XSHM (the X shared memory extension), resulting
|
---|
729 | in reduced overhead for painting operations.
|
---|
730 |
|
---|
731 | A new OpenGL ES 2.0-based paint engine complements the existing OpenGL paint
|
---|
732 | engine, but with a focus on embedded devices.
|
---|
733 |
|
---|
734 | Qt now features a pluggable graphics system, making it possible for users
|
---|
735 | and developers to select raster, OpenGL or native graphics systems to take
|
---|
736 | into account the specific needs of their applications and get the best
|
---|
737 | performance out of them.
|
---|
738 |
|
---|
739 | \section1 Mac OS X Cocoa Support
|
---|
740 |
|
---|
741 | \image mac-cocoa.png
|
---|
742 |
|
---|
743 | Qt for Mac OS X has been substantially rewritten to use Apple's Cocoa API,
|
---|
744 | enabling Qt applications to be deployed on 64-bit Macintosh hardware.
|
---|
745 | In addition, the new QMacCocoaViewContainer and QMacNativeWidget classes
|
---|
746 | provide integration with Cocoa's own features and controls.
|
---|
747 |
|
---|
748 | For many applications, a simple recompilation is all that is required
|
---|
749 | to produce an executable for 64-bit systems. Applications that use
|
---|
750 | specific features may require a few changes first.
|
---|
751 |
|
---|
752 | \section1 Windows CE Feature Parity
|
---|
753 |
|
---|
754 | Qt for Windows CE has been updated to bring features of Qt 4.4 and Qt 4.5
|
---|
755 | to the Windows CE platform, including:
|
---|
756 |
|
---|
757 | \list
|
---|
758 | \o Phonon Multimedia Framework, using a Direct-Show based backend for audio
|
---|
759 | and video playback and a Simple WaveOut backend for devices without DirectShow.
|
---|
760 | \o The inclusion of Qt WebKit integration features previously unavailable for
|
---|
761 | Qt 4.4 on Windows CE.
|
---|
762 | \endlist
|
---|
763 |
|
---|
764 | Support on all Windows CE platforms; recommended for WinCE 6 and higher.
|
---|
765 |
|
---|
766 | The inclusion of these features enables developers to easily integrate Web and
|
---|
767 | multimedia content into Qt applications on Windows CE Standard Edition while
|
---|
768 | retaining full cross-platform compatibility with other Qt platforms.
|
---|
769 |
|
---|
770 | \section1 XML Transformations with XSLT
|
---|
771 |
|
---|
772 | The QtXmlPatterns module has been extended to cover XSLT, a transformation language
|
---|
773 | for XML documents. A common application of this is the transformation of XML data
|
---|
774 | into human-readable formats for reporting purposes.
|
---|
775 |
|
---|
776 | XSLT makes it simple to reformat XML content without changing data structures,
|
---|
777 | removes the need for an intermediate DOM layer for presentation, and enables
|
---|
778 | rapid solutions to be created; for example, creating reports as HTML or PDF.
|
---|
779 |
|
---|
780 | \section1 Qt Script Debugger
|
---|
781 |
|
---|
782 | \image qtscript-debugger-small.png
|
---|
783 |
|
---|
784 | Developers using Qt Script in their applications can take advantage of
|
---|
785 | the new \l{Qt Script Debugger Manual}{Qt Script Debugger} to provide
|
---|
786 | error reporting for scripts, and to let users track down bugs in their
|
---|
787 | own scripts.
|
---|
788 |
|
---|
789 | Many standard features of GUI debugging tools are present, allowing the
|
---|
790 | developer to step through running script code, inspect variables,
|
---|
791 | automatically catch exceptions, and set conditional breakpoints.
|
---|
792 |
|
---|
793 | \section1 OpenDocument File Format Support
|
---|
794 |
|
---|
795 | Qt 4.5 includes support for writing rich text documents as OpenDocument files via
|
---|
796 | the newly-introduced QTextDocumentWriter class. This provides an generic mechanism
|
---|
797 | for file export that can be used to introduce support for additional formats in
|
---|
798 | future releases.
|
---|
799 |
|
---|
800 | \section1 Improved Network Proxy Support
|
---|
801 |
|
---|
802 | Qt's networking classes have been updated with
|
---|
803 | \l{QtNetwork Module#Support for Network Proxies}{improved proxy support}.
|
---|
804 | This includes improved integration with system proxy settings and the added
|
---|
805 | ability to handle non-trivial proxy cases.
|
---|
806 |
|
---|
807 | \section1 Qt Designer Improvements
|
---|
808 |
|
---|
809 | \image designer-screenshot-small.png
|
---|
810 |
|
---|
811 | Qt Designer 4.5 boasts some improvements on usability, for example:
|
---|
812 |
|
---|
813 | \list
|
---|
814 | \o \bold{Icon Mode} for the widget box which substantially reduces
|
---|
815 | scrolling.
|
---|
816 | \o \bold{Morphing Widgets} which lets you morph similar widget types,
|
---|
817 | e.g., a QWidget to a QFrame, types via the context menu's
|
---|
818 | \e{Morph into} entry.
|
---|
819 | \o \bold{Filters} for the \gui{Property Editor} that lets you find
|
---|
820 | properties or widgets quickly.
|
---|
821 | \o \bold{Find option} for the \gui{Object Inspector} that performs an
|
---|
822 | incremental search on the form's widgets. Also, the objects' layout
|
---|
823 | state is displayed here with using an icon on the left. Broken
|
---|
824 | layouts are represented with the same icon used for the
|
---|
825 | \e{Break Layout} action.
|
---|
826 | \endlist
|
---|
827 |
|
---|
828 | In addition, Qt Designer now features an \gui{Embedded Design} tab that can
|
---|
829 | be found in the \gui Preferences dialog. Within this tab, you can define
|
---|
830 | embedded device profiles. These profiles contains screen settings, e.g.,
|
---|
831 | display resolution, default font and default style. Qt Designer will use
|
---|
832 | these settings when you edit forms.
|
---|
833 |
|
---|
834 | More information about these improvements can be found in the
|
---|
835 | \l{What's New in Qt Designer 4.5} overview.
|
---|
836 |
|
---|
837 | \section1 Qt Linguist Improvements
|
---|
838 |
|
---|
839 | Qt Linguist can now load and edit multiple translation files simultaneously.
|
---|
840 |
|
---|
841 | Support for XML Localization Interchange File Format (XLIFF) files, previously added
|
---|
842 | to the \c lupdate tool in Qt 4.3, has been improved and extended to the rest of the
|
---|
843 | Qt Linguist toolchain. This enables files stored in Qt's TS translation format to
|
---|
844 | be exported for use with other tools.
|
---|
845 |
|
---|
846 | The GNU Gettext PO format, which is commonly used in Open Source projects,
|
---|
847 | is now supported by Qt Linguist.
|
---|
848 |
|
---|
849 | Support for a new way to annotate messages, using comments in the source code,
|
---|
850 | has been added to the toolchain. See the QObject::tr() documentation for a detailed
|
---|
851 | description and examples.
|
---|
852 |
|
---|
853 | The new \c lconvert filter tool facilitates conversion between file formats and
|
---|
854 | can be used to perform other transformations on collections of translatable strings.
|
---|
855 |
|
---|
856 | \section1 Graphics Enhancements
|
---|
857 |
|
---|
858 | In addition to the performance improvements in this release, a number of graphics
|
---|
859 | enhancements extend support for existing features to more platforms and expand Qt's
|
---|
860 | core set of features with successful add-ons.
|
---|
861 |
|
---|
862 | Widget style sheets can now be used on Mac OS X, making this approach to theming
|
---|
863 | and styling viable for truly cross-platform applications.
|
---|
864 |
|
---|
865 | Support for ARGB top-level widgets, previously available as a separate solution,
|
---|
866 | is now provided as an integral part of Qt. This makes it possible to create windows
|
---|
867 | with translucent regions on systems with the appropriate support from the user's
|
---|
868 | window system. See the \l{QWidget#Creating Translucent Windows}{Creating Translucent
|
---|
869 | Windows} section of the QWidget documentation for details of this feature.
|
---|
870 |
|
---|
871 |
|
---|
872 | \image gtk-style-screenshot.png
|
---|
873 |
|
---|
874 | Improved GTK+ integration provided by the QGtkStyle class improves the look and feel
|
---|
875 | of Qt applications in GNOME and other GTK-based environments. The screenshot above
|
---|
876 | illustrates this clearly.
|
---|
877 | */
|
---|