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
|
---|
|
---|