| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** 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 are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 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.4:
|
|---|
| 82 | \list
|
|---|
| 83 | \o \l{QtWebkit Module}{Qt WebKit integration}, making it possible for developers
|
|---|
| 84 | to use a fully-featured Web browser to display documents and access online
|
|---|
| 85 | services.
|
|---|
| 86 | \o A multimedia API provided by the \l{Phonon Overview}{Phonon Multimedia Framework}.
|
|---|
| 87 | \o \l{QtXmlPatterns Module}{XQuery and XPath} support, providing facilities for
|
|---|
| 88 | XML processing beyond that supported by the QtXml module.
|
|---|
| 89 | \o Support for embedded widgets in \l{Graphics View} scenes.
|
|---|
| 90 | \o The \l{Threading and Concurrent Programming}{QtConcurrent framework} for
|
|---|
| 91 | concurrent programming using Qt paradigms and threading features.
|
|---|
| 92 | \o An \l{QtHelp Module}{improved help system} that can be used in conjunction
|
|---|
| 93 | with Qt Assistant or as an independent help resource manager.
|
|---|
| 94 | \o Printing system improvements, including the QPrinterInfo, QPrintPreviewWidget
|
|---|
| 95 | and QPrintPreviewDialog classes.
|
|---|
| 96 | \o Support for \l{Windows CE - Introduction to using Qt}{Qt for Windows CE} as
|
|---|
| 97 | a mainstream Qt platform.
|
|---|
| 98 | \o Improvements in performance of Qt for Embedded Linux and extended support for
|
|---|
| 99 | display hardware.
|
|---|
| 100 | \endlist
|
|---|
| 101 |
|
|---|
| 102 | In Qt 4.3:
|
|---|
| 103 | \list
|
|---|
| 104 | \o Support for different \l{The Qt 4 Main Window Classes}{main window paradigms and styles},
|
|---|
| 105 | such as those found in Visual Studio or KDevelop.
|
|---|
| 106 | \o The \l{QtScript} module, providing support for application scripting with ECMAScript.
|
|---|
| 107 | \o Improved graphics features, including an experimental Direct3D paint engine
|
|---|
| 108 | and improved provision for hardware accelerated rendering with OpenGL, and
|
|---|
| 109 | support for OpenGL ES in Qt for Embedded Linux.
|
|---|
| 110 | \o \l{QSvgGenerator}{Scalable Vector Graphics (SVG) export}, allowing SVG drawings to
|
|---|
| 111 | be created using the standard QPainter API.
|
|---|
| 112 | \o Support for arbitrary matrix transformations and set operations on painter paths.
|
|---|
| 113 | \o Native look and feel on Windows Vista; improved look and feel on Mac OS X.
|
|---|
| 114 | \o An improved \l{QMdiArea}{Multiple Document Interface (MDI)} implementation.
|
|---|
| 115 | \o Continuous improvements to \QD, including support for
|
|---|
| 116 | \l{Qt Designer's Widget Editing Mode#The Property Editor}{dynamic properties}.
|
|---|
| 117 | \o Support for Secure Socket Layer (SSL) communications via the QSslSocket class.
|
|---|
| 118 | \o Support for XML Localization Interchange File Format (XLIFF) files in \QL.
|
|---|
| 119 | \o A new font subsystem for Qt for Embedded Linux.
|
|---|
| 120 | \endlist
|
|---|
| 121 |
|
|---|
| 122 | In Qt 4.2:
|
|---|
| 123 | \list
|
|---|
| 124 | \o The \l{Graphics View} framework for producing interactive graphics.
|
|---|
| 125 | \o \l{Desktop Integration}{Desktop integration} facilities for applications.
|
|---|
| 126 | \o \l{Qt Style Sheets} enable easy, yet powerful customization of
|
|---|
| 127 | user interfaces.
|
|---|
| 128 | \o Support for the \l{intro-to-dbus.html}{D-Bus} Inter-Process Communication (IPC) and Remote Procedure Calling (RPC) mechanism.
|
|---|
| 129 | \o An \l{Undo Framework}{Undo framework} based on the
|
|---|
| 130 | \l{Books about GUI Design#Design Patterns}{Command pattern}.
|
|---|
| 131 | \o Support for model-based \l{QCompleter}{text completion} in standard and
|
|---|
| 132 | custom widgets.
|
|---|
| 133 | \o New widgets and GUI features, such as QCalendarWidget and
|
|---|
| 134 | QGLFramebufferObject.
|
|---|
| 135 | \o Classes to provide higher level application infrastructure, such as
|
|---|
| 136 | QFileSystemWatcher and QDataWidgetMapper.
|
|---|
| 137 | \endlist
|
|---|
| 138 |
|
|---|
| 139 | In Qt 4.1:
|
|---|
| 140 | \list
|
|---|
| 141 | \o Integrated support for rendering
|
|---|
| 142 | \l{The Arthur Paint System#SVG Rendering Support}{Scalable Vector Graphics}
|
|---|
| 143 | (SVG) drawings and animations.
|
|---|
| 144 | \o Support for
|
|---|
| 145 | \l{QWidget#Transparency and Double Buffering}{child widget transparency}
|
|---|
| 146 | on all platforms.
|
|---|
| 147 | \o A Portable Document Format (PDF) backend for Qt's printing system.
|
|---|
| 148 | \o A \l{QTestLib Manual}{unit testing framework} for Qt applications and
|
|---|
| 149 | libraries.
|
|---|
| 150 | \o Modules for \l{QtDesigner}{extending \QD} and
|
|---|
| 151 | \l{QtUiTools}{dynamic user interface building}.
|
|---|
| 152 | \o New \l{Proxy Models}{proxy models} to enable view-specific sorting and
|
|---|
| 153 | filtering of data displayed using item views.
|
|---|
| 154 | \o Support for \l{Installing Qt on Mac OS X}{universal binaries} on Mac OS X.
|
|---|
| 155 | \o Additional features for developers using \l{QtOpenGL}{OpenGL}, such as
|
|---|
| 156 | support for pixel and sample buffers.
|
|---|
| 157 | \o A flexible \l{QSyntaxHighlighter}{syntax highlighting class} based on the
|
|---|
| 158 | \l{Scribe} rich text framework.
|
|---|
| 159 | \o Support for \l{QNetworkProxy}{network proxy} servers using the SOCKS5
|
|---|
| 160 | protocol.
|
|---|
| 161 | \o Support for OLE verbs and MIME data handling in \l{ActiveQt}.
|
|---|
| 162 | \endlist
|
|---|
| 163 |
|
|---|
| 164 | For more information about improvements in each Qt release, see
|
|---|
| 165 | the \l{http://www.qtsoftware.com/developer/changes/}
|
|---|
| 166 | {detailed lists of changes}.
|
|---|
| 167 |
|
|---|
| 168 | \section1 Significant Improvements
|
|---|
| 169 |
|
|---|
| 170 | The following modules have been significantly improved for Qt 4:
|
|---|
| 171 |
|
|---|
| 172 | \list
|
|---|
| 173 | \o A fully cross-platform \l{accessibility}
|
|---|
| 174 | module, with support for the emerging SP-API Unix standard in
|
|---|
| 175 | addition to Microsoft and Mac Accessibility.
|
|---|
| 176 | \o The \l{qt4-sql.html}{SQL module}, which is now based on the
|
|---|
| 177 | Interview model/view framework.
|
|---|
| 178 | \o The \l{qt4-network.html}{network module}, with better support
|
|---|
| 179 | for UDP and synchronous sockets.
|
|---|
| 180 | \o The \l{qt4-styles.html}{style API}, which is now decoupled from
|
|---|
| 181 | the widgets, meaning that you can draw any user interface element on
|
|---|
| 182 | any device (widget, pixmap, etc.).
|
|---|
| 183 | \o Enhanced \l{qt4-threads.html}{thread support}, with signal-slot
|
|---|
| 184 | connections across threads and per-thread event loops.
|
|---|
| 185 | \o A new \l{resource system} for embedding images
|
|---|
| 186 | and other resource files into the application executable.
|
|---|
| 187 | \endlist
|
|---|
| 188 |
|
|---|
| 189 | \section1 Build System
|
|---|
| 190 |
|
|---|
| 191 | Unlike previous Qt releases, Qt 4 is a collection of smaller
|
|---|
| 192 | libraries:
|
|---|
| 193 |
|
|---|
| 194 | \table
|
|---|
| 195 | \header \o Library \o Description
|
|---|
| 196 | \row \o \l{QtCore} \o Core non-GUI functionality
|
|---|
| 197 | \row \o \l{QtGui} \o Core GUI functionality
|
|---|
| 198 | \row \o \l{QtNetwork} \o Network module
|
|---|
| 199 | \row \o \l{QtOpenGL} \o OpenGL module
|
|---|
| 200 | \row \o \l{QtSql} \o SQL module
|
|---|
| 201 | \row \o \l{QtSvg} \o SVG rendering classes
|
|---|
| 202 | \row \o \l{QtXml} \o XML module
|
|---|
| 203 | \row \o \l{Qt3Support} \o Qt 3 support classes
|
|---|
| 204 | \row \o \l{QAxContainer} \o ActiveQt client extension
|
|---|
| 205 | \row \o \l{QAxServer} \o ActiveQt server extension
|
|---|
| 206 | \row \o \l{QtAssistant} \o Classes for launching Qt Assistant
|
|---|
| 207 | \row \o \l{QtDesigner} \o Classes for extending and embedding Qt Designer
|
|---|
| 208 | \row \o \l{QtUiTools} \o Classes for dynamic GUI generation
|
|---|
| 209 | \row \o \l{QtTest} \o Tool classes for unit testing
|
|---|
| 210 | \endtable
|
|---|
| 211 |
|
|---|
| 212 | QtCore contains tool classes like QString, QList, and QFile, as
|
|---|
| 213 | well as kernel classes like QObject and QTimer. The QApplication
|
|---|
| 214 | class has been refactored so that it can be used in non-GUI
|
|---|
| 215 | applications. It is split into QCoreApplication (in \l QtCore)
|
|---|
| 216 | and QApplication (in \l QtGui).
|
|---|
| 217 |
|
|---|
| 218 | This split makes it possible to develop server applications using Qt
|
|---|
| 219 | without linking in any unnecessary GUI-related code and without
|
|---|
| 220 | requiring GUI-related system libraries to be present on the target
|
|---|
| 221 | machine (e.g. Xlib on X11, Carbon on Mac OS X).
|
|---|
| 222 |
|
|---|
| 223 | If you use qmake to generate your makefiles, qmake will by default
|
|---|
| 224 | link your application against QtCore and QtGui. To remove the
|
|---|
| 225 | dependency upon QtGui, add the line
|
|---|
| 226 |
|
|---|
| 227 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 0
|
|---|
| 228 |
|
|---|
| 229 | to your .pro file. To enable the other libraries, add the line
|
|---|
| 230 |
|
|---|
| 231 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 1
|
|---|
| 232 |
|
|---|
| 233 | Another change to the build system is that moc now understands
|
|---|
| 234 | preprocessor directives. qmake automatically passes the defines set
|
|---|
| 235 | for your project (using "DEFINES +=") on to moc, which has its own
|
|---|
| 236 | built-in C++ preprocessor.
|
|---|
| 237 |
|
|---|
| 238 | To compile code that uses .ui files, you will also need this line in
|
|---|
| 239 | the .pro file:
|
|---|
| 240 |
|
|---|
| 241 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 2
|
|---|
| 242 |
|
|---|
| 243 | \section1 Include Syntax
|
|---|
| 244 |
|
|---|
| 245 | The syntax for including Qt class definitions has become
|
|---|
| 246 |
|
|---|
| 247 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 3
|
|---|
| 248 |
|
|---|
| 249 | For example:
|
|---|
| 250 |
|
|---|
| 251 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 4
|
|---|
| 252 |
|
|---|
| 253 | This is guaranteed to work for any public Qt class. The old syntax,
|
|---|
| 254 |
|
|---|
| 255 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 5
|
|---|
| 256 |
|
|---|
| 257 | still works, but we encourage you to switch to the new syntax.
|
|---|
| 258 |
|
|---|
| 259 | If you attempt to include a header file from a library that isn't
|
|---|
| 260 | linked against the application, this will result in a
|
|---|
| 261 | compile-time warning (e.g., "QSqlQuery: No such file or
|
|---|
| 262 | directory"). You can remedy to this problem either by removing
|
|---|
| 263 | the offending include or by specifying the missing library in the
|
|---|
| 264 | QT entry of your \c .pro file (see \l{Build System} above).
|
|---|
| 265 |
|
|---|
| 266 | To include the definitions for all the classes in a library, simply
|
|---|
| 267 | specify the name of that library. For example:
|
|---|
| 268 |
|
|---|
| 269 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 6
|
|---|
| 270 |
|
|---|
| 271 | \section1 Namespaces
|
|---|
| 272 |
|
|---|
| 273 | Qt 2 introduced a class called Qt for global-like constants
|
|---|
| 274 | (e.g., \c{Qt::yellow}). The C++ namespace construct was not used
|
|---|
| 275 | because not all compilers understood it when it was released.
|
|---|
| 276 |
|
|---|
| 277 | With Qt 4, the Qt class has become the Qt namespace. If you want
|
|---|
| 278 | to access a constant that is part of the Qt namespace, prefix it
|
|---|
| 279 | with \c Qt:: (e.g., \c{Qt::yellow}), or add the directive
|
|---|
| 280 |
|
|---|
| 281 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 7
|
|---|
| 282 |
|
|---|
| 283 | at the top of your source files, after your \c #include
|
|---|
| 284 | directives. If you use the \c{using namespace} syntax you don't
|
|---|
| 285 | need the prefix (e.g., \c yellow is sufficient).
|
|---|
| 286 |
|
|---|
| 287 | When porting Qt 3 applications, you may run into some source
|
|---|
| 288 | compatibility problems with some of these symbols. For example,
|
|---|
| 289 | in Qt 3, it was legal to write \c QWidget::yellow instead of \c
|
|---|
| 290 | Qt::yellow, because QWidget inherited from Qt. This won't work in
|
|---|
| 291 | Qt 4; you must write \c Qt::yellow or add the "using namespace"
|
|---|
| 292 | directive and drop the \c Qt:: prefix.
|
|---|
| 293 |
|
|---|
| 294 | The \l{qt3to4 - The Qt 3 to 4 Porting Tool}{qt3to4} porting tool
|
|---|
| 295 | automates this conversion.
|
|---|
| 296 |
|
|---|
| 297 | \section1 QObject/QWidget Constructors
|
|---|
| 298 |
|
|---|
| 299 | In Qt 4 we have tried to simplify the constructors of QObject/QWidget
|
|---|
| 300 | subclasses. This makes subclassing easier, at the same time as it
|
|---|
| 301 | helps make the Qt library more efficient.
|
|---|
| 302 |
|
|---|
| 303 | Constructors no longer take a "const char *name" parameter. If
|
|---|
| 304 | you want to specify a name for a QObject, you must call
|
|---|
| 305 | QObject::setObjectName() after construction. The object name is
|
|---|
| 306 | now a QString. The reasons for this change are:
|
|---|
| 307 |
|
|---|
| 308 | \list
|
|---|
| 309 | \o Code that used it looked confusing, for example:
|
|---|
| 310 |
|
|---|
| 311 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 8
|
|---|
| 312 |
|
|---|
| 313 | \c label1 is a QLabel that displays the text "Hello"; \c
|
|---|
| 314 | label2 is a QLabel with no text, with the object name
|
|---|
| 315 | "Hello".
|
|---|
| 316 |
|
|---|
| 317 | \o From surveys we did, most users didn't use the name, although
|
|---|
| 318 | they blindly followed Qt's convention and provided a "const
|
|---|
| 319 | char *name" in their subclasses's constructors. For example:
|
|---|
| 320 |
|
|---|
| 321 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 9
|
|---|
| 322 |
|
|---|
| 323 | \o The name parameter was in Qt since version 1, and it always
|
|---|
| 324 | was documented as: "It is not very useful in the current
|
|---|
| 325 | version of Qt, but it will become increasingly important in
|
|---|
| 326 | the future." Ten years later, it still hasn't fulfilled its
|
|---|
| 327 | promise.
|
|---|
| 328 | \endlist
|
|---|
| 329 |
|
|---|
| 330 | QWidget's \c WFlags data type has been split in two:
|
|---|
| 331 | Qt::WindowFlags specifies low-level window flags (the type of
|
|---|
| 332 | window and the frame style), whereas Qt::WidgetAttribute
|
|---|
| 333 | specifies various higher-level attributes about the widget (e.g.,
|
|---|
| 334 | WA_StaticContents). Widget attributes can be set at any time
|
|---|
| 335 | using QWidget::setAttribute(); low-level window flags can be
|
|---|
| 336 | passed to the QWidget constructor or set later using
|
|---|
| 337 | QWidget::setParent(). As a consequence, the constructors of most
|
|---|
| 338 | QWidget subclasses don't need to provide a \c WFlags parameter.
|
|---|
| 339 |
|
|---|
| 340 | The \e parent parameter of all QObject classes in Qt defaults to
|
|---|
| 341 | a 0 pointer, as it used to do in Qt 1. This enables a style of
|
|---|
| 342 | programming where widgets are created without parents and then
|
|---|
| 343 | inserted in a layout, at which point the layout automatically
|
|---|
| 344 | reparents them.
|
|---|
| 345 |
|
|---|
| 346 | \section1 Dynamic Casts
|
|---|
| 347 |
|
|---|
| 348 | Qt 4 provides a qobject_cast<>() function that performs a dynamic cast
|
|---|
| 349 | based on the meta-information generated by moc for QObject
|
|---|
| 350 | subclasses. Unlike the standard C++ dynamic_cast<>() construct,
|
|---|
| 351 | qobject_cast<>() works even when RTTI is disabled, and it works correctly
|
|---|
| 352 | across DLL boundaries.
|
|---|
| 353 |
|
|---|
| 354 | Here's the Qt 3 idiom to cast a type to a subtype:
|
|---|
| 355 |
|
|---|
| 356 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 10
|
|---|
| 357 |
|
|---|
| 358 | The Qt 4 idiom is both cleaner and safer, because typos will always
|
|---|
| 359 | result in compiler errors:
|
|---|
| 360 |
|
|---|
| 361 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 11
|
|---|
| 362 |
|
|---|
| 363 | \section1 QPointer<T>
|
|---|
| 364 |
|
|---|
| 365 | The QPointer<T> class provides a pointer to type T (where T inherits
|
|---|
| 366 | from QObject) that is automatically set to 0 when the referenced
|
|---|
| 367 | object is destroyed. Guarded pointers are useful whenever you want to
|
|---|
| 368 | store a pointer to an object you do not own.
|
|---|
| 369 |
|
|---|
| 370 | Example:
|
|---|
| 371 |
|
|---|
| 372 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 12
|
|---|
| 373 |
|
|---|
| 374 | QPointer<T> is more or less the same as the old QGuardedPtr<T> class,
|
|---|
| 375 | except that it is now implemented in a much more lightweight manner
|
|---|
| 376 | than before. The cost of one QPointer<T> object is now approximately
|
|---|
| 377 | the same as that of a signal--slot connection.
|
|---|
| 378 |
|
|---|
| 379 | \section1 Paint Events
|
|---|
| 380 |
|
|---|
| 381 | Qt 4 supports double buffering transparently on all platforms. This
|
|---|
| 382 | feature can be turned off on a per-widget basis by calling
|
|---|
| 383 | QWidget::setAttribute(Qt::WA_PaintOnScreen).
|
|---|
| 384 |
|
|---|
| 385 | A consequence of this is that all painting must now be done from the
|
|---|
| 386 | paintEvent() function. This is also required by the HIView API on Mac
|
|---|
| 387 | OS X. In practice, this is seldom a problem, since you can call
|
|---|
| 388 | update() from anywhere in your code to create a paint event, with the
|
|---|
| 389 | region to update as the argument.
|
|---|
| 390 |
|
|---|
| 391 | To help porting, QWidget supports a Qt::WA_PaintOutsidePaintEvent
|
|---|
| 392 | attribute that can be set to make it possible to paint outside
|
|---|
| 393 | \l{QWidget::paintEvent()}{paintEvent()} on Windows and X11.
|
|---|
| 394 |
|
|---|
| 395 | \section1 Qt 3 Support Layer
|
|---|
| 396 |
|
|---|
| 397 | Qt 4 provides an extension library that applications based on Qt 3,
|
|---|
| 398 | called Qt3Support, that Qt applications can link against. This allows
|
|---|
| 399 | for more compatibility than ever before, without bloating Qt.
|
|---|
| 400 |
|
|---|
| 401 | \list
|
|---|
| 402 | \o Classes that have been replaced by a different class with the
|
|---|
| 403 | same name, such as QListView, and classes that no longer exist in Qt 4
|
|---|
| 404 | are available with a \c 3 in their name (e.g., Q3ListView, Q3Accel).
|
|---|
| 405 |
|
|---|
| 406 | \o Other classes provide compatibility functions. Most of these are
|
|---|
| 407 | implemented inline, so that they don't bloat the Qt libraries.
|
|---|
| 408 | \endlist
|
|---|
| 409 |
|
|---|
| 410 | To enable the Qt 3 support classes and functions, add the line
|
|---|
| 411 |
|
|---|
| 412 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 13
|
|---|
| 413 |
|
|---|
| 414 | to your \c .pro file.
|
|---|
| 415 |
|
|---|
| 416 | On Visual C++ 7 and GCC 3.2+, using compatibility functions often results
|
|---|
| 417 | in a compiler warning (e.g., "'find' is deprecated"). If you want to turn
|
|---|
| 418 | off that warning, add the line
|
|---|
| 419 |
|
|---|
| 420 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 14
|
|---|
| 421 |
|
|---|
| 422 | to your \c .pro file.
|
|---|
| 423 |
|
|---|
| 424 | If you want to use compatibility functions but don't want to link
|
|---|
| 425 | against the Qt3Support library, add the line
|
|---|
| 426 |
|
|---|
| 427 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 15
|
|---|
| 428 |
|
|---|
| 429 | or
|
|---|
| 430 |
|
|---|
| 431 | \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 16
|
|---|
| 432 |
|
|---|
| 433 | to your \c .pro file, depending on whether you want compatibility
|
|---|
| 434 | function calls to generate compiler warnings or not.
|
|---|
| 435 | */
|
|---|
| 436 |
|
|---|
| 437 | /*!
|
|---|
| 438 | \page qt4-5-intro.html
|
|---|
| 439 | \title What's New in Qt 4.5
|
|---|
| 440 |
|
|---|
| 441 | Qt 4.5 provides many improvements and enhancements over the previous releases
|
|---|
| 442 | in the Qt 4 series. This document covers the most important features in this
|
|---|
| 443 | release, separated by category.
|
|---|
| 444 |
|
|---|
| 445 | A comprehensive list of changes between Qt 4.4 and Qt 4.5 is included
|
|---|
| 446 | in the \c changes-4.5.0 file
|
|---|
| 447 | \l{http://www.qtsoftware.com/developer/changes/changes-4.5.0}{available online}.
|
|---|
| 448 | A \l{Known Issues in 4.5.1}{list of known issues} for this release is also
|
|---|
| 449 | available.
|
|---|
| 450 |
|
|---|
| 451 | Changes between this release and the previous release are provided
|
|---|
| 452 | in the \c{changes-4.5.1} file (also
|
|---|
| 453 | \l{http://www.qtsoftware.com/developer/changes/changes-4.5.1}{available online}).
|
|---|
| 454 |
|
|---|
| 455 | A list of other Qt 4 features can be found on the
|
|---|
| 456 | \bold{\l{What's New in Qt 4}} page.
|
|---|
| 457 |
|
|---|
| 458 | \bold{Highlights}
|
|---|
| 459 |
|
|---|
| 460 | \tableofcontents
|
|---|
| 461 |
|
|---|
| 462 | \section1 Qt WebKit Integration
|
|---|
| 463 |
|
|---|
| 464 | \image webkit-netscape-plugin.png
|
|---|
| 465 |
|
|---|
| 466 | The WebKit browser engine included with Qt has been upgraded to the latest
|
|---|
| 467 | upstream (trunk) version of WebKit, bringing the latest features and
|
|---|
| 468 | improvements to Qt applications. These include:
|
|---|
| 469 |
|
|---|
| 470 | \list
|
|---|
| 471 | \o Support for full page zooming, with appropriate rescaling of images and fonts.
|
|---|
| 472 | \o The CSS-based transformation and animation features provided by a WebKit
|
|---|
| 473 | extension.
|
|---|
| 474 | \o Performance improvements due to faster JavaScript engine and optimized
|
|---|
| 475 | page loading.
|
|---|
| 476 | \endlist
|
|---|
| 477 |
|
|---|
| 478 | Standards compatibility improvements include provision for the Netscape plugin
|
|---|
| 479 | API, allowing most Netscape plugins to be used in-process, support for HTML 5
|
|---|
| 480 | audio and video elements using Qt's Phonon integration, and
|
|---|
| 481 | \l{Web Application Support}{facilities for client-side storage of Web content}.
|
|---|
| 482 |
|
|---|
| 483 | \section1 Performance Improvements
|
|---|
| 484 |
|
|---|
| 485 | The introduction of the QtBenchLib performance benchmarking library enables
|
|---|
| 486 | performance benchmarking and regression testing. Core parts of Qt itself have
|
|---|
| 487 | undergone focused re-engineering for improved graphics performance, including
|
|---|
| 488 | paint engine and text rendering improvements, Graphics View and style sheet
|
|---|
| 489 | performance improvements.
|
|---|
| 490 |
|
|---|
| 491 | The X11 paint engine now uses XSHM (the X shared memory extension), resulting
|
|---|
| 492 | in reduced overhead for painting operations.
|
|---|
| 493 |
|
|---|
| 494 | A new OpenGL ES 2.0-based paint engine complements the existing OpenGL paint
|
|---|
| 495 | engine, but with a focus on embedded devices.
|
|---|
| 496 |
|
|---|
| 497 | Qt now features a pluggable graphics system, making it possible for users
|
|---|
| 498 | and developers to select raster, OpenGL or native graphics systems to take
|
|---|
| 499 | into account the specific needs of their applications and get the best
|
|---|
| 500 | performance out of them.
|
|---|
| 501 |
|
|---|
| 502 | \section1 Mac OS X Cocoa Support
|
|---|
| 503 |
|
|---|
| 504 | \image mac-cocoa.png
|
|---|
| 505 |
|
|---|
| 506 | Qt for Mac OS X has been substantially rewritten to use Apple's Cocoa API,
|
|---|
| 507 | enabling Qt applications to be deployed on 64-bit Macintosh hardware.
|
|---|
| 508 | In addition, the new QMacCocoaViewContainer and QMacNativeWidget classes
|
|---|
| 509 | provide integration with Cocoa's own features and controls.
|
|---|
| 510 |
|
|---|
| 511 | For many applications, a simple recompilation is all that is required
|
|---|
| 512 | to produce an executable for 64-bit systems. Applications that use
|
|---|
| 513 | specific features may require a few changes first.
|
|---|
| 514 |
|
|---|
| 515 | \section1 Windows CE Feature Parity
|
|---|
| 516 |
|
|---|
| 517 | Qt for Windows CE has been updated to bring features of Qt 4.4 and Qt 4.5
|
|---|
| 518 | to the Windows CE platform, including:
|
|---|
| 519 |
|
|---|
| 520 | \list
|
|---|
| 521 | \o Phonon Multimedia Framework, using a Direct-Show based backend for audio
|
|---|
| 522 | and video playback and a Simple WaveOut backend for devices without DirectShow.
|
|---|
| 523 | \o The inclusion of Qt WebKit integration features previously unavailable for
|
|---|
| 524 | Qt 4.4 on Windows CE.
|
|---|
| 525 | \endlist
|
|---|
| 526 |
|
|---|
| 527 | Support on all Windows CE platforms; recommended for WinCE 6 and higher.
|
|---|
| 528 |
|
|---|
| 529 | The inclusion of these features enables developers to easily integrate Web and
|
|---|
| 530 | multimedia content into Qt applications on Windows CE Standard Edition while
|
|---|
| 531 | retaining full cross-platform compatibility with other Qt platforms.
|
|---|
| 532 |
|
|---|
| 533 | \section1 XML Transformations with XSLT
|
|---|
| 534 |
|
|---|
| 535 | The QtXmlPatterns module has been extended to cover XSLT, a transformation language
|
|---|
| 536 | for XML documents. A common application of this is the transformation of XML data
|
|---|
| 537 | into human-readable formats for reporting purposes.
|
|---|
| 538 |
|
|---|
| 539 | XSLT makes it simple to reformat XML content without changing data structures,
|
|---|
| 540 | removes the need for an intermediate DOM layer for presentation, and enables
|
|---|
| 541 | rapid solutions to be created; for example, creating reports as HTML or PDF.
|
|---|
| 542 |
|
|---|
| 543 | \section1 Qt Script Debugger
|
|---|
| 544 |
|
|---|
| 545 | \image qtscript-debugger-small.png
|
|---|
| 546 |
|
|---|
| 547 | Developers using Qt Script in their applications can take advantage of
|
|---|
| 548 | the new \l{Qt Script Debugger Manual}{Qt Script Debugger} to provide
|
|---|
| 549 | error reporting for scripts, and to let users track down bugs in their
|
|---|
| 550 | own scripts.
|
|---|
| 551 |
|
|---|
| 552 | Many standard features of GUI debugging tools are present, allowing the
|
|---|
| 553 | developer to step through running script code, inspect variables,
|
|---|
| 554 | automatically catch exceptions, and set conditional breakpoints.
|
|---|
| 555 |
|
|---|
| 556 | \section1 OpenDocument File Format Support
|
|---|
| 557 |
|
|---|
| 558 | Qt 4.5 includes support for writing rich text documents as OpenDocument files via
|
|---|
| 559 | the newly-introduced QTextDocumentWriter class. This provides an generic mechanism
|
|---|
| 560 | for file export that can be used to introduce support for additional formats in
|
|---|
| 561 | future releases.
|
|---|
| 562 |
|
|---|
| 563 | \section1 Improved Network Proxy Support
|
|---|
| 564 |
|
|---|
| 565 | Qt's networking classes have been updated with
|
|---|
| 566 | \l{QtNetwork Module#Support for Network Proxies}{improved proxy support}.
|
|---|
| 567 | This includes improved integration with system proxy settings and the added
|
|---|
| 568 | ability to handle non-trivial proxy cases.
|
|---|
| 569 |
|
|---|
| 570 | \section1 Qt Designer Improvements
|
|---|
| 571 |
|
|---|
| 572 | \image designer-screenshot-small.png
|
|---|
| 573 |
|
|---|
| 574 | Qt Designer 4.5 boasts some improvements on usability, for example:
|
|---|
| 575 |
|
|---|
| 576 | \list
|
|---|
| 577 | \o \bold{Icon Mode} for the widget box which substantially reduces
|
|---|
| 578 | scrolling.
|
|---|
| 579 | \o \bold{Morphing Widgets} which lets you morph similar widget types,
|
|---|
| 580 | e.g., a QWidget to a QFrame, types via the context menu's
|
|---|
| 581 | \e{Morph into} entry.
|
|---|
| 582 | \o \bold{Filters} for the \gui{Property Editor} that lets you find
|
|---|
| 583 | properties or widgets quickly.
|
|---|
| 584 | \o \bold{Find option} for the \gui{Object Inspector} that performs an
|
|---|
| 585 | incremental search on the form's widgets. Also, the objects' layout
|
|---|
| 586 | state is displayed here with using an icon on the left. Broken
|
|---|
| 587 | layouts are represented with the same icon used for the
|
|---|
| 588 | \e{Break Layout} action.
|
|---|
| 589 | \endlist
|
|---|
| 590 |
|
|---|
| 591 | In addition, Qt Designer now features an \gui{Embedded Design} tab that can
|
|---|
| 592 | be found in the \gui Preferences dialog. Within this tab, you can define
|
|---|
| 593 | embedded device profiles. These profiles contains screen settings, e.g.,
|
|---|
| 594 | display resolution, default font and default style. Qt Designer will use
|
|---|
| 595 | these settings when you edit forms.
|
|---|
| 596 |
|
|---|
| 597 | More information about these improvements can be found in the
|
|---|
| 598 | \l{What's New in Qt Designer 4.5} overview.
|
|---|
| 599 |
|
|---|
| 600 | \section1 Qt Linguist Improvements
|
|---|
| 601 |
|
|---|
| 602 | Qt Linguist can now load and edit multiple translation files simultaneously.
|
|---|
| 603 |
|
|---|
| 604 | Support for XML Localization Interchange File Format (XLIFF) files, previously added
|
|---|
| 605 | to the \c lupdate tool in Qt 4.3, has been improved and extended to the rest of the
|
|---|
| 606 | Qt Linguist toolchain. This enables files stored in Qt's TS translation format to
|
|---|
| 607 | be exported for use with other tools.
|
|---|
| 608 |
|
|---|
| 609 | The GNU Gettext PO format, which is commonly used in Open Source projects,
|
|---|
| 610 | is now supported by Qt Linguist.
|
|---|
| 611 |
|
|---|
| 612 | Support for a new way to annotate messages, using comments in the source code,
|
|---|
| 613 | has been added to the toolchain. See the QObject::tr() documentation for a detailed
|
|---|
| 614 | description and examples.
|
|---|
| 615 |
|
|---|
| 616 | The new \c lconvert filter tool facilitates conversion between file formats and
|
|---|
| 617 | can be used to perform other transformations on collections of translatable strings.
|
|---|
| 618 |
|
|---|
| 619 | \section1 Graphics Enhancements
|
|---|
| 620 |
|
|---|
| 621 | In addition to the performance improvements in this release, a number of graphics
|
|---|
| 622 | enhancements extend support for existing features to more platforms and expand Qt's
|
|---|
| 623 | core set of features with successful add-ons.
|
|---|
| 624 |
|
|---|
| 625 | Widget style sheets can now be used on Mac OS X, making this approach to theming
|
|---|
| 626 | and styling viable for truly cross-platform applications.
|
|---|
| 627 |
|
|---|
| 628 | Support for ARGB top-level widgets, previously available as a separate solution,
|
|---|
| 629 | is now provided as an integral part of Qt. This makes it possible to create windows
|
|---|
| 630 | with translucent regions on systems with the appropriate support from the user's
|
|---|
| 631 | window system. See the \l{QWidget#Creating Translucent Windows}{Creating Translucent
|
|---|
| 632 | Windows} section of the QWidget documentation for details of this feature.
|
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 | \image gtk-style-screenshot.png
|
|---|
| 636 |
|
|---|
| 637 | Improved GTK+ integration provided by the QGtkStyle class improves the look and feel
|
|---|
| 638 | of Qt applications in GNOME and other GTK-based environments. The screenshot above
|
|---|
| 639 | illustrates this clearly.
|
|---|
| 640 | */
|
|---|