1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 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:FDL$
|
---|
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 a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \page qt4-intro.html
|
---|
30 | \title What's New in Qt 4
|
---|
31 |
|
---|
32 | \startpage index.html Qt Reference Documentation
|
---|
33 | \nextpage The Tulip Container Classes
|
---|
34 |
|
---|
35 | This document covers the most important differences between Qt 3
|
---|
36 | and Qt 4. Although it is not intended to be a comprehensive
|
---|
37 | porting guide, it tells you about the most important portability
|
---|
38 | issues that you may encounter. It also explains how to turn on Qt
|
---|
39 | 3 compatibility support.
|
---|
40 |
|
---|
41 | \section1 New Technologies in Qt 4
|
---|
42 |
|
---|
43 | Qt 4 introduces the following core technologies:
|
---|
44 |
|
---|
45 | \list
|
---|
46 | \o \l{The Tulip Container Classes}{Tulip}, a new set of template container classes.
|
---|
47 |
|
---|
48 | \o \l{The Interview Framework}{Interview}, a model/view architecture for item views.
|
---|
49 |
|
---|
50 | \o \l{The Arthur Paint System}{Arthur}, the Qt 4 painting framework.
|
---|
51 |
|
---|
52 | \o \l{The Scribe Classes}{Scribe}, the Unicode text renderer with a public API
|
---|
53 | for performing low-level text layout.
|
---|
54 |
|
---|
55 | \o \l{The Qt 4 Main Window Classes}{Mainwindow}, a modern action-based
|
---|
56 | mainwindow, toolbar, menu, and docking architecture.
|
---|
57 |
|
---|
58 | \o The new \l{The New Qt Designer}{\QD} user interface design tool.
|
---|
59 | \endlist
|
---|
60 |
|
---|
61 | \section1 Recent Additions to Qt 4
|
---|
62 |
|
---|
63 | The following features have been added to Qt since the first release of Qt 4.
|
---|
64 |
|
---|
65 | In Qt 4.7:
|
---|
66 | \list
|
---|
67 | \o Declarative UI Development with \l{Qt Quick}, technologies for creating
|
---|
68 | fluid, dynamic user interfaces.
|
---|
69 | \o Support for \l{Bearer Management}{network bearer management}, enabling
|
---|
70 | features such as control over network interfaces and support for roaming
|
---|
71 | between networks.
|
---|
72 | \o Feature and performance improvements in QtWebKit, including a new tiled
|
---|
73 | backing store, control over scroll bars used in frames and framesets,
|
---|
74 | accelerated compositing and \l{The QtWebKit Bridge}{support for hybrid
|
---|
75 | development}.
|
---|
76 | \o General performance improvements, including the use of "alien widgets"
|
---|
77 | on Mac OS X, the QStaticText class for optimized text rendering, a new
|
---|
78 | \l{QPainter::drawPixmapFragments()}{API for rendering pixmap fragments}
|
---|
79 | and an updated version of the JavaScriptCore engine for the QtScript
|
---|
80 | module with improved performance.
|
---|
81 | \endlist
|
---|
82 |
|
---|
83 | In Qt 4.6:
|
---|
84 | \list
|
---|
85 | \o Support for \l{The Symbian platform - Introduction to Qt}{the Symbian Platform}
|
---|
86 | as a mainstream Qt platform, with integration into the S60 framework.
|
---|
87 | \o The \l{The Animation Framework}{animation framework} allows animations to be
|
---|
88 | created using both widgets and graphics items.
|
---|
89 | \o The \l{The State Machine Framework}{state machine framework} provides a robust
|
---|
90 | state chart implementation based on Harel statecharts and SCXML.
|
---|
91 | \o Support for \l{QTouchEvent}{touch input} and \l{Gestures Programming}{gestures}
|
---|
92 | enable developers to create intuitive user interfaces for touch-based devices.
|
---|
93 | \o A \l{QWebElement}{DOM access API} for QtWebKit provides a cleaner and safer way
|
---|
94 | to access elements and structures of Web pages without the use of JavaScript.
|
---|
95 | \o A collection of performance improvements, covering QGraphicsView, QPixmapCache,
|
---|
96 | QNetworkAccessManager, QContiguousCache class, hardware-accelerated rendering
|
---|
97 | support through \l{OpenVG Rendering in Qt}{OpenVG}, and the removal of Win9x
|
---|
98 | support.
|
---|
99 | \o A collection of \l{QGraphicsEffect}{graphics effects} make it easy to apply
|
---|
100 | and simple effects to graphics items and combine them to produce more complex
|
---|
101 | effects.
|
---|
102 | \o Support for XML schema validation in the QtXmlPatterns module covering
|
---|
103 | large parts of version 1.0 of the specification.
|
---|
104 | \o Qt3D enablers, including math primitives for \l{QMatrix4x4}{matrix multiplication},
|
---|
105 | \l{QVector3D}{vectors}, \l{QQuaternion}{quaternions} (client-side), and an API
|
---|
106 | for \l{QGLShader}{vertex and fragment shaders}, GLSL/ES.
|
---|
107 | \o \l{QtMultimedia Module}{Multimedia services} providing low-level access to the
|
---|
108 | system's audio system.
|
---|
109 | \endlist
|
---|
110 |
|
---|
111 | In Qt 4.5:
|
---|
112 | \list
|
---|
113 | \o The WebKit browser engine included with Qt has been
|
---|
114 | upgraded to the latest upstream (trunk) version of WebKit,
|
---|
115 | bringing the latest features and improvements to Qt applications.
|
---|
116 | \o Qt for Mac OS X has been substantially rewritten to use
|
---|
117 | Apple's Cocoa API, enabling Qt applications to be deployed on
|
---|
118 | 64-bit Macintosh hardware.
|
---|
119 | \o The QtXmlPatterns module has been extended to cover XSLT, a
|
---|
120 | transformation language for XML documents.
|
---|
121 | \o Qt Script introduced its debugger,
|
---|
122 | providing error reporting for scripts, and to let users track down
|
---|
123 | bugs in their own scripts.
|
---|
124 | \o Qt 4.5 includes support for writing rich text documents as
|
---|
125 | OpenDocument files via the newly-introduced QTextDocumentWriter
|
---|
126 | class.
|
---|
127 | \o Qt Linguist can load and edit multiple translation
|
---|
128 | files simultaneously.
|
---|
129 | \o Support for ARGB top-level widgets (i.e., translucent
|
---|
130 | windows).
|
---|
131 | \endlist
|
---|
132 |
|
---|
133 | In Qt 4.4:
|
---|
134 | \list
|
---|
135 | \o \l{Webkit in QT}{Qt WebKit integration}, making it possible for developers
|
---|
136 | to use a fully-featured Web browser to display documents and access online
|
---|
137 | services.
|
---|
138 | \o A multimedia API provided by the \l{Phonon Overview}{Phonon Multimedia Framework}.
|
---|
139 | \o \l{QtXmlPatterns Module}{XQuery and XPath} support, providing facilities for
|
---|
140 | XML processing beyond that supported by the QtXml module.
|
---|
141 | \o Support for embedded widgets in \l{Graphics View} scenes.
|
---|
142 | \o The \l{Thread Support in Qt}{QtConcurrent framework} for
|
---|
143 | concurrent programming using Qt paradigms and threading features.
|
---|
144 | \o An \l{QtHelp Module}{improved help system} that can be used in conjunction
|
---|
145 | with Qt Assistant or as an independent help resource manager.
|
---|
146 | \o Printing system improvements, including the QPrinterInfo, QPrintPreviewWidget
|
---|
147 | and QPrintPreviewDialog classes.
|
---|
148 | \o Support for \l{Windows CE - Introduction to using Qt}{Qt for Windows CE} as
|
---|
149 | a mainstream Qt platform.
|
---|
150 | \o Improvements in performance of Qt for Embedded Linux and extended support for
|
---|
151 | display hardware.
|
---|
152 | \endlist
|
---|
153 |
|
---|
154 | In Qt 4.3:
|
---|
155 | \list
|
---|
156 | \o Support for different \l{The Qt 4 Main Window Classes}{main window paradigms and styles},
|
---|
157 | such as those found in Visual Studio or KDevelop.
|
---|
158 | \o The \l{QtScript} module, providing support for application scripting with ECMAScript.
|
---|
159 | \o Improved graphics features, including an experimental Direct3D paint engine
|
---|
160 | and improved provision for hardware accelerated rendering with OpenGL, and
|
---|
161 | support for OpenGL ES in Qt for Embedded Linux.
|
---|
162 | \o \l{QSvgGenerator}{Scalable Vector Graphics (SVG) export}, allowing SVG drawings to
|
---|
163 | be created using the standard QPainter API.
|
---|
164 | \o Support for arbitrary matrix transformations and set operations on painter paths.
|
---|
165 | \o Native look and feel on Windows Vista; improved look and feel on Mac OS X.
|
---|
166 | \o An improved \l{QMdiArea}{Multiple Document Interface (MDI)} implementation.
|
---|
167 | \o Continuous improvements to \QD, including support for
|
---|
168 | \l{Qt Designer's Widget Editing Mode#The Property Editor}{dynamic properties}.
|
---|
169 | \o Support for Secure Socket Layer (SSL) communications via the QSslSocket class.
|
---|
170 | \o Support for XML Localization Interchange File Format (XLIFF) files in \QL.
|
---|
171 | \o A new font subsystem for Qt for Embedded Linux.
|
---|
172 | \endlist
|
---|
173 |
|
---|
174 | In Qt 4.2:
|
---|
175 | \list
|
---|
176 | \o The \l{Graphics View} framework for producing interactive graphics.
|
---|
177 | \o \l{Desktop Integration}{Desktop integration} facilities for applications.
|
---|
178 | \o \l{Qt Style Sheets} enable easy, yet powerful customization of
|
---|
179 | user interfaces.
|
---|
180 | \o Support for the \l{intro-to-dbus.html}{D-Bus} Inter-Process Communication (IPC) and Remote Procedure Calling (RPC) mechanism.
|
---|
181 | \o An \l{Undo Framework}{Undo framework} based on the
|
---|
182 | \l{Books about GUI Design#Design Patterns}{Command pattern}.
|
---|
183 | \o Support for model-based \l{QCompleter}{text completion} in standard and
|
---|
184 | custom widgets.
|
---|
185 | \o New widgets and GUI features, such as QCalendarWidget and
|
---|
186 | QGLFramebufferObject.
|
---|
187 | \o Classes to provide higher level application infrastructure, such as
|
---|
188 | QFileSystemWatcher and QDataWidgetMapper.
|
---|
189 | \endlist
|
---|
190 |
|
---|
191 | In Qt 4.1:
|
---|
192 | \list
|
---|
193 | \o Integrated support for rendering
|
---|
194 | \l{The Arthur Paint System#SVG Rendering Support}{Scalable Vector Graphics}
|
---|
195 | (SVG) drawings and animations.
|
---|
196 | \o Support for
|
---|
197 | \l{QWidget#Transparency and Double Buffering}{child widget transparency}
|
---|
198 | on all platforms.
|
---|
199 | \o A Portable Document Format (PDF) backend for Qt's printing system.
|
---|
200 | \o A \l{QTestLib Manual}{unit testing framework} for Qt applications and
|
---|
201 | libraries.
|
---|
202 | \o Modules for \l{QtDesigner}{extending \QD} and
|
---|
203 | \l{QtUiTools}{dynamic user interface building}.
|
---|
204 | \o New \l{Proxy Models}{proxy models} to enable view-specific sorting and
|
---|
205 | filtering of data displayed using item views.
|
---|
206 | \o Support for \l{Installing Qt for Mac OS X}{universal binaries} on Mac OS X.
|
---|
207 | \o Additional features for developers using \l{QtOpenGL}{OpenGL}, such as
|
---|
208 | support for pixel and sample buffers.
|
---|
209 | \o A flexible \l{QSyntaxHighlighter}{syntax highlighting class} based on the
|
---|
210 | \l{Scribe} rich text framework.
|
---|
211 | \o Support for \l{QNetworkProxy}{network proxy} servers using the SOCKS5
|
---|
212 | protocol.
|
---|
213 | \o Support for OLE verbs and MIME data handling in \l{ActiveQt}.
|
---|
214 | \endlist
|
---|
215 |
|
---|
216 | For more information about improvements in each Qt release, see
|
---|
217 | the \l{http://qt.nokia.com/developer/changes/}
|
---|
218 | {detailed lists of changes}.
|
---|
219 |
|
---|
220 | \section1 Significant Improvements
|
---|
221 |
|
---|
222 | The following modules have been significantly improved for Qt 4:
|
---|
223 |
|
---|
224 | \list
|
---|
225 | \o A fully cross-platform \l{accessibility}
|
---|
226 | module, with support for the emerging SP-API Unix standard in
|
---|
227 | addition to Microsoft and Mac Accessibility.
|
---|
228 | \o The \l{qt4-sql.html}{SQL module}, which is now based on the
|
---|
229 | Interview model/view framework.
|
---|
230 | \o The \l{qt4-network.html}{network module}, with better support
|
---|
231 | for UDP and synchronous sockets.
|
---|
232 | \o The \l{qt4-styles.html}{style API}, which is now decoupled from
|
---|
233 | the widgets, meaning that you can draw any user interface element on
|
---|
234 | any device (widget, pixmap, etc.).
|
---|
235 | \o Enhanced \l{qt4-threads.html}{thread support}, with signal-slot
|
---|
236 | connections across threads and per-thread event loops.
|
---|
237 | \o A new \l{resource system} for embedding images
|
---|
238 | and other resource files into the application executable.
|
---|
239 | \endlist
|
---|
240 |
|
---|
241 | \section1 Build System
|
---|
242 |
|
---|
243 | Unlike previous Qt releases, Qt 4 is a collection of smaller
|
---|
244 | libraries:
|
---|
245 |
|
---|
246 | \table
|
---|
247 | \header \o Library \o Description
|
---|
248 | \row \o \l{QtCore} \o Core non-GUI functionality
|
---|
249 | \row \o \l{QtGui} \o Core GUI functionality
|
---|
250 | \row \o \l{QtNetwork} \o Network module
|
---|
251 | \row \o \l{QtOpenGL} \o OpenGL module
|
---|
252 | \row \o \l{QtSql} \o SQL module
|
---|
253 | \row \o \l{QtSvg} \o SVG rendering classes
|
---|
254 | \row \o \l{QtXml} \o XML module
|
---|
255 | \row \o \l{Qt3Support} \o Qt 3 support classes
|
---|
256 | \row \o \l{QAxContainer} \o ActiveQt client extension
|
---|
257 | \row \o \l{QAxServer} \o ActiveQt server extension
|
---|
258 | \row \o \l{QtHelp} \o Classes for integrating online documentation
|
---|
259 | \row \o \l{QtDesigner} \o Classes for extending and embedding Qt Designer
|
---|
260 | \row \o \l{QtUiTools} \o Classes for dynamic GUI generation
|
---|
261 | \row \o \l{QtTest} \o Tool classes for unit testing
|
---|
262 | \endtable
|
---|
263 |
|
---|
264 | QtCore contains tool classes like QString, QList, and QFile, as
|
---|
265 | well as kernel classes like QObject and QTimer. The QApplication
|
---|
266 | class has been refactored so that it can be used in non-GUI
|
---|
267 | applications. It is split into QCoreApplication (in \l QtCore)
|
---|
268 | and QApplication (in \l QtGui).
|
---|
269 |
|
---|
270 | This split makes it possible to develop server applications using Qt
|
---|
271 | without linking in any unnecessary GUI-related code and without
|
---|
272 | requiring GUI-related system libraries to be present on the target
|
---|
273 | machine (e.g. Xlib on X11, Carbon on Mac OS X).
|
---|
274 |
|
---|
275 | If you use qmake to generate your makefiles, qmake will by default
|
---|
276 | link your application against QtCore and QtGui. To remove the
|
---|
277 | dependency upon QtGui, add the line
|
---|
278 |
|
---|
279 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 0
|
---|
280 |
|
---|
281 | to your .pro file. To enable the other libraries, add the line
|
---|
282 |
|
---|
283 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 1
|
---|
284 |
|
---|
285 | Another change to the build system is that moc now understands
|
---|
286 | preprocessor directives. qmake automatically passes the defines set
|
---|
287 | for your project (using "DEFINES +=") on to moc, which has its own
|
---|
288 | built-in C++ preprocessor.
|
---|
289 |
|
---|
290 | To compile code that uses UI files, you will also need this line in
|
---|
291 | the .pro file:
|
---|
292 |
|
---|
293 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 2
|
---|
294 |
|
---|
295 | \section1 Include Syntax
|
---|
296 |
|
---|
297 | The syntax for including Qt class definitions has become
|
---|
298 |
|
---|
299 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 3
|
---|
300 |
|
---|
301 | For example:
|
---|
302 |
|
---|
303 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 4
|
---|
304 |
|
---|
305 | This is guaranteed to work for any public Qt class. The old syntax,
|
---|
306 |
|
---|
307 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 5
|
---|
308 |
|
---|
309 | still works, but we encourage you to switch to the new syntax.
|
---|
310 |
|
---|
311 | If you attempt to include a header file from a library that isn't
|
---|
312 | linked against the application, this will result in a
|
---|
313 | compile-time warning (e.g., "QSqlQuery: No such file or
|
---|
314 | directory"). You can remedy to this problem either by removing
|
---|
315 | the offending include or by specifying the missing library in the
|
---|
316 | QT entry of your \c .pro file (see \l{Build System} above).
|
---|
317 |
|
---|
318 | To include the definitions for all the classes in a library, simply
|
---|
319 | specify the name of that library. For example:
|
---|
320 |
|
---|
321 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 6
|
---|
322 |
|
---|
323 | \section1 Namespaces
|
---|
324 |
|
---|
325 | Qt 2 introduced a class called Qt for global-like constants
|
---|
326 | (e.g., \c{Qt::yellow}). The C++ namespace construct was not used
|
---|
327 | because not all compilers understood it when it was released.
|
---|
328 |
|
---|
329 | With Qt 4, the Qt class has become the Qt namespace. If you want
|
---|
330 | to access a constant that is part of the Qt namespace, prefix it
|
---|
331 | with \c Qt:: (e.g., \c{Qt::yellow}), or add the directive
|
---|
332 |
|
---|
333 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 7
|
---|
334 |
|
---|
335 | at the top of your source files, after your \c #include
|
---|
336 | directives. If you use the \c{using namespace} syntax you don't
|
---|
337 | need the prefix (e.g., \c yellow is sufficient).
|
---|
338 |
|
---|
339 | When porting Qt 3 applications, you may run into some source
|
---|
340 | compatibility problems with some of these symbols. For example,
|
---|
341 | in Qt 3, it was legal to write \c QWidget::yellow instead of \c
|
---|
342 | Qt::yellow, because QWidget inherited from Qt. This won't work in
|
---|
343 | Qt 4; you must write \c Qt::yellow or add the "using namespace"
|
---|
344 | directive and drop the \c Qt:: prefix.
|
---|
345 |
|
---|
346 | The \l{qt3to4 - The Qt 3 to 4 Porting Tool}{qt3to4} porting tool
|
---|
347 | automates this conversion.
|
---|
348 |
|
---|
349 | \section1 QObject/QWidget Constructors
|
---|
350 |
|
---|
351 | In Qt 4 we have tried to simplify the constructors of QObject/QWidget
|
---|
352 | subclasses. This makes subclassing easier, at the same time as it
|
---|
353 | helps make the Qt library more efficient.
|
---|
354 |
|
---|
355 | Constructors no longer take a "const char *name" parameter. If
|
---|
356 | you want to specify a name for a QObject, you must call
|
---|
357 | QObject::setObjectName() after construction. The object name is
|
---|
358 | now a QString. The reasons for this change are:
|
---|
359 |
|
---|
360 | \list
|
---|
361 | \o Code that used it looked confusing, for example:
|
---|
362 |
|
---|
363 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 8
|
---|
364 |
|
---|
365 | \c label1 is a QLabel that displays the text "Hello"; \c
|
---|
366 | label2 is a QLabel with no text, with the object name
|
---|
367 | "Hello".
|
---|
368 |
|
---|
369 | \o From surveys we did, most users didn't use the name, although
|
---|
370 | they blindly followed Qt's convention and provided a "const
|
---|
371 | char *name" in their subclasses's constructors. For example:
|
---|
372 |
|
---|
373 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 9
|
---|
374 |
|
---|
375 | \o The name parameter was in Qt since version 1, and it always
|
---|
376 | was documented as: "It is not very useful in the current
|
---|
377 | version of Qt, but it will become increasingly important in
|
---|
378 | the future." Ten years later, it still hasn't fulfilled its
|
---|
379 | promise.
|
---|
380 | \endlist
|
---|
381 |
|
---|
382 | QWidget's \c WFlags data type has been split in two:
|
---|
383 | Qt::WindowFlags specifies low-level window flags (the type of
|
---|
384 | window and the frame style), whereas Qt::WidgetAttribute
|
---|
385 | specifies various higher-level attributes about the widget (e.g.,
|
---|
386 | WA_StaticContents). Widget attributes can be set at any time
|
---|
387 | using QWidget::setAttribute(); low-level window flags can be
|
---|
388 | passed to the QWidget constructor or set later using
|
---|
389 | QWidget::setParent(). As a consequence, the constructors of most
|
---|
390 | QWidget subclasses don't need to provide a \c WFlags parameter.
|
---|
391 |
|
---|
392 | The \e parent parameter of all QObject classes in Qt defaults to
|
---|
393 | a 0 pointer, as it used to do in Qt 1. This enables a style of
|
---|
394 | programming where widgets are created without parents and then
|
---|
395 | inserted in a layout, at which point the layout automatically
|
---|
396 | reparents them.
|
---|
397 |
|
---|
398 | \section1 Dynamic Casts
|
---|
399 |
|
---|
400 | Qt 4 provides a qobject_cast<>() function that performs a dynamic cast
|
---|
401 | based on the meta-information generated by moc for QObject
|
---|
402 | subclasses. Unlike the standard C++ dynamic_cast<>() construct,
|
---|
403 | qobject_cast<>() works even when RTTI is disabled, and it works correctly
|
---|
404 | across DLL boundaries.
|
---|
405 |
|
---|
406 | Here's the Qt 3 idiom to cast a type to a subtype:
|
---|
407 |
|
---|
408 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 10
|
---|
409 |
|
---|
410 | The Qt 4 idiom is both cleaner and safer, because typos will always
|
---|
411 | result in compiler errors:
|
---|
412 |
|
---|
413 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 11
|
---|
414 |
|
---|
415 | \section1 QPointer<T>
|
---|
416 |
|
---|
417 | The QPointer<T> class provides a pointer to type T (where T inherits
|
---|
418 | from QObject) that is automatically set to 0 when the referenced
|
---|
419 | object is destroyed. Guarded pointers are useful whenever you want to
|
---|
420 | store a pointer to an object you do not own.
|
---|
421 |
|
---|
422 | Example:
|
---|
423 |
|
---|
424 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 12
|
---|
425 |
|
---|
426 | QPointer<T> is more or less the same as the old QGuardedPtr<T> class,
|
---|
427 | except that it is now implemented in a much more lightweight manner
|
---|
428 | than before. The cost of one QPointer<T> object is now approximately
|
---|
429 | the same as that of a signal--slot connection.
|
---|
430 |
|
---|
431 | \section1 Paint Events
|
---|
432 |
|
---|
433 | Qt 4 supports double buffering transparently on all platforms. This
|
---|
434 | feature can be turned off on a per-widget basis by calling
|
---|
435 | QWidget::setAttribute(Qt::WA_PaintOnScreen).
|
---|
436 |
|
---|
437 | A consequence of this is that all painting must now be done from the
|
---|
438 | paintEvent() function. This is also required by the HIView API on Mac
|
---|
439 | OS X. In practice, this is seldom a problem, since you can call
|
---|
440 | update() from anywhere in your code to create a paint event, with the
|
---|
441 | region to update as the argument.
|
---|
442 |
|
---|
443 | To help porting, QWidget supports a Qt::WA_PaintOutsidePaintEvent
|
---|
444 | attribute that can be set to make it possible to paint outside
|
---|
445 | \l{QWidget::paintEvent()}{paintEvent()} on Windows and X11.
|
---|
446 |
|
---|
447 | \section1 Qt 3 Support Layer
|
---|
448 |
|
---|
449 | Qt 4 provides an extension library that applications based on Qt 3,
|
---|
450 | called Qt3Support, that Qt applications can link against. This allows
|
---|
451 | for more compatibility than ever before, without bloating Qt.
|
---|
452 |
|
---|
453 | \list
|
---|
454 | \o Classes that have been replaced by a different class with the
|
---|
455 | same name, such as QListView, and classes that no longer exist in Qt 4
|
---|
456 | are available with a \c 3 in their name (e.g., Q3ListView, Q3Accel).
|
---|
457 |
|
---|
458 | \o Other classes provide compatibility functions. Most of these are
|
---|
459 | implemented inline, so that they don't bloat the Qt libraries.
|
---|
460 | \endlist
|
---|
461 |
|
---|
462 | To enable the Qt 3 support classes and functions, add the line
|
---|
463 |
|
---|
464 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 13
|
---|
465 |
|
---|
466 | to your \c .pro file.
|
---|
467 |
|
---|
468 | On Visual C++ 7 and GCC 3.2+, using compatibility functions often results
|
---|
469 | in a compiler warning (e.g., "'find' is deprecated"). If you want to turn
|
---|
470 | off that warning, add the line
|
---|
471 |
|
---|
472 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 14
|
---|
473 |
|
---|
474 | to your \c .pro file.
|
---|
475 |
|
---|
476 | If you want to use compatibility functions but don't want to link
|
---|
477 | against the Qt3Support library, add the line
|
---|
478 |
|
---|
479 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 15
|
---|
480 |
|
---|
481 | or
|
---|
482 |
|
---|
483 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 16
|
---|
484 |
|
---|
485 | to your \c .pro file, depending on whether you want compatibility
|
---|
486 | function calls to generate compiler warnings or not.
|
---|
487 | */
|
---|
488 |
|
---|
489 | /*!
|
---|
490 | \page qt4-7-intro.html
|
---|
491 | \title What's New in Qt 4.7
|
---|
492 |
|
---|
493 | Qt 4.7 provides many improvements and enhancements over the
|
---|
494 | previous releases in the Qt 4 series. This document covers the
|
---|
495 | most important features in this release, separated by category.
|
---|
496 |
|
---|
497 | A list of other Qt 4 features can be found on the \bold{\l{What's
|
---|
498 | New in Qt 4}} page.
|
---|
499 |
|
---|
500 | \section1 Declarative UI Development with Qt Quick
|
---|
501 |
|
---|
502 | \image quick_screens.png
|
---|
503 |
|
---|
504 | Qt 4.7 introduces \l{Qt Quick}, the Qt UI Creation Kit. that enables
|
---|
505 | the creation of dynamic user interfaces, easier and more effective
|
---|
506 | than possible with existing UI technologies. This UI Creation Kit
|
---|
507 | consists of three technologies:
|
---|
508 |
|
---|
509 | \list
|
---|
510 | \i QML is a declarative language oriented on JavaScript that utilizes
|
---|
511 | Qt's Meta-Object capabilities to enable designers and developers to
|
---|
512 | collaborate tightly and create animated and fluid user experiences,
|
---|
513 | using existing knowledge in script language and design.
|
---|
514 |
|
---|
515 | \i Qt Declarative is a C++ library that provides the underlying engine,
|
---|
516 | which translates the declarative description of the UI in QML into
|
---|
517 | items on a QGraphicsScene. The library also provides APIs to bind
|
---|
518 | custom C++ types and elements to QML, and to connect the QML UI with
|
---|
519 | the underlying application logic written in C++.
|
---|
520 |
|
---|
521 | \i Qt Creator has been improved to support interactive editing of
|
---|
522 | QML UIs through drag-and-drop. The text editor supports the QML
|
---|
523 | syntax and provides authoring assistance such as auto-completion,
|
---|
524 | error lookup, help lookup and easy preview of QML UI's. The Qt
|
---|
525 | Quick features in Qt Creator will be released with Qt Creator 2.1
|
---|
526 | \endlist
|
---|
527 |
|
---|
528 | \section1 Network Bearer Management
|
---|
529 |
|
---|
|
---|