What's New in Qt 4.6

Qt 4.6 provides many improvements and enhancements over the previous releases in the Qt 4 series. This document covers the most important features in this release, separated by category.

A list of other Qt 4 features can be found on the What's New in Qt 4 page.

Support for Symbian

Qt 4.6 is the first release to include support for the Symbian platform, with integration into the S60 framework. The port to Symbian and S60 provides all functionality required to develop rich end-user applications for devices running S60 3.1 and later.

See the The Symbian platform - Introduction to Qt for more information.

Animation Framework

The animation framework helps build highly animated, high-performance GUIs without the hassle of managing complex structures, timers, and easing curves, not to mention the large state graphs that all animated GUIs tend to be full of.

The framework makes it easy to animate QObjects, including QWidgets, by allowing Qt properties to be animated. It also allows creating custom animations and interpolation functions. Graphics views are not left out; one can animate QGraphicsWidgets and new QGraphicsObjects which inherit from QGraphicsItem (and thereby enable properties).

Animations are controlled using easing curves and can be grouped together. This enables animations of arbitrary complexity.

The API is easy to grasp with functions such as start(), stop(), pause(), and currentTime(). Here is an image from one of the examples that come with the framework:

The animation framework also plugs into the new Qt Statemachine by allowing an animation to be played when transitions are triggered. The state machine framework is introduced in 4.6 and is described below.

See The Animation Framework documentation for more information.

State Machine Framework

The state machine framework provides a robust state chart implementation based on Harel statecharts and SCXML. Qt's API lets you construct such state graphs and execute them. The key benefits of a state machine are:

  • Simplify complex application semantics.
  • Use of states to reduce code bloat.
  • Use states to improve maintainability.
  • Makes event-driven programming robust and more reusable.

It is especially the last item here that makes using a state machine worthwhile. A key characteristic of event-driven systems (such as Qt applications) is that behavior often depends not only on the last or current event, but also the events that preceded it. With statecharts, this information is easy to express.

The framework fits neatly into Qt by allowing transitions to trigger on signals and QEvents. By inserting animations into the state machine, it is also easier to use the framework for animating GUIs, for instance.

See The State Machine Framework documentation for more information.

Touch and Gestures

Support for touch input enables users to interact with many parts of a user interface at the same time, and provides the basis for gestures. Additional infrastructure for gesture recognition allows a sequence of touch inputs to be combined to create gestures that can be used to activate features and trigger actions in an application.

This new functionality brings a number of benefits:

  • Allows users to interact with applications in more natural ways.
  • Simplifies finger-based interaction with UI components.
  • Combines support for common basic gestures and touch gestures in a single general framework.
  • Enables extensibility by design.

See the QTouchEvent class documentation for more information on touch input and QGestureEvent for gestures.

DOM Access API

Web pages and XML both have very complex document object models. The W3C selector API provides a very simple way to access and manipulate such structures. This API makes it intuitive to access DOM, helps reuse CSS selector knowledge, and gives little maintenance or footprint overhead.

    QWebElement document = frame->documentElement();
    /* Assume the document has the following structure:

       <p class=intro>

    QWebElementCollection allSpans = document.findAll("span");
    QWebElementCollection introSpans = document.findAll("p.intro span");

See the QWebElement class documentation for more information.

Performance Optimizations

As always, Qt continuously strive to optimize its performance. For this release, we have:

Graphics Effects

Effects can be used to alter the appearance of UI elements such as QGraphicsItems and QWidgets. A couple of standard effects such as blurring, colorizing and drop shadow are provided, and it is possible to implement custom effects.

See the QGraphicsEffect class documentation for more information.

XML Schema Validation

The QtXmlPatterns module can now be used to validate schemas, either through C++ APIs in the Qt application, or using the xmlpatternsvalidator command line utility. The implementation of XML Schema Validation supports the specification version 1.0 in large parts.

See the XML Processing and QXmlSchema class documentation for more information.

Qt3D Enablers

As more of Qt, and more of the applications built on Qt go 3D, API's should be provided to simplify this. Mainly, the new API aims to make it more easy to create 3D applications with OpenGL. It will also unify the Qt OpenGL codebase, and enable cross-platform 3D codebase.

The main features of the Qt3D enablers are currently: Math primitives for matrix multiplication, vectors, quaternions (client-side), and an API for vertex and fragment shaders, GLSL/ES. Future research will, among other things include stencils, scissors, vertex buffers and arrays, texture manipulation, and geometry shaders.

Multimedia Services

Qt 4.6 comes with new classes for handling audio. These classes provide low-level access to the system's audio system. By specifying the audio format (QAudioFormat) and supplying audio data through a QIODevice, you get direct access to the functionality of the sound device. The API also comes with functions to query audio devices for which audio formats they support.

See the QtMultimedia Module documentation for more information.

New Classes, Functions, Macros, etc.

Links to new classes, functions, macros, and other items introduced in Qt 4.6.

New Namespaces

namespace QAudio

New Classes

const_iterator (QWebElementCollection)
ErrorPageExtensionOption (QWebPage)
ErrorPageExtensionReturn (QWebPage)
iterator (QWebElementCollection)
Key (QPixmapCache)
QTouchEventSequence (QTest)
SignalEvent (QStateMachine)
TouchPoint (QTouchEvent)
WrappedEvent (QStateMachine)

New Member Functions

Class QWebHitTestResult:

QWebElement element() const
QWebElement enclosingBlockElement() const
QWebElement linkElement() const

Class QWebDatabase:

Class QWebFrame:

void contentsSizeChanged(const QSize & size)
QWebElement documentElement() const
QWebElementCollection findAllElements(const QString & selectorQuery) const
QWebElement findFirstElement(const QString & selectorQuery) const
void loadFinished(bool ok)
void loadStarted()
void render(QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion())
QRect scrollBarGeometry(Qt::Orientation orientation) const
void setFocus()

Class QWebPage:

QWebFrame * frameAt(const QPoint & pos) const
bool shouldInterruptJavaScript()

Class QWebSecurityOrigin:

void addLocalScheme(const QString & scheme)
QStringList localSchemes()
void removeLocalScheme(const QString & scheme)

Class QWebSettings:

void clearMemoryCaches()
QString defaultTextEncoding() const
void enablePersistentStorage(const QString & path = QString())
QString localStoragePath() const
QString offlineWebApplicationCachePath()
qint64 offlineWebApplicationCacheQuota()
void setDefaultTextEncoding(const QString & encoding)
void setLocalStoragePath(const QString & path)
void setOfflineWebApplicationCachePath(const QString & path)
void setOfflineWebApplicationCacheQuota(qint64 maximumSize)

Class QWebView:

QPainter::RenderHints renderHints() const
void setRenderHint(QPainter::RenderHint hint, bool enabled = true)
void setRenderHints(QPainter::RenderHints hints)

Class QTextCodec:

QTextCodec * codecForUtfText(const QByteArray & ba, QTextCodec * defaultCodec)

Class QLibraryInfo:

QDate buildDate()

Class QSysInfo:

S60Version s60Version()
SymbianVersion symbianVersion()

Class QDataStream:

FloatingPointPrecision floatingPointPrecision() const
void setFloatingPointPrecision(FloatingPointPrecision precision)

Class QProcessEnvironment:

QProcessEnvironment systemEnvironment()

Class QProcess:

QProcessEnvironment processEnvironment() const
void setProcessEnvironment(const QProcessEnvironment & environment)

Class QUrl:

QUrl fromUserInput(const QString & userInput)

Class QAbstractItemModel:

bool beginMoveColumns(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
bool beginMoveRows(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
void beginResetModel()
void columnsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void endMoveColumns()
void endMoveRows()
void endResetModel()
const QHash<int, QByteArray> & roleNames() const
void rowsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void rowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void setRoleNames(const QHash<int, QByteArray> & roleNames)

Class QMetaMethod:

int methodIndex() const

Class QMetaProperty:

bool isConstant() const
bool isFinal() const
int notifySignalIndex() const
int propertyIndex() const

Class QVariant:

float toFloat(bool * ok = 0) const
qreal toReal(bool * ok = 0) const

Class QByteArray:

QByteArray & insert(int i, const char * str, int len)
QByteArray & prepend(const char * str, int len)

Class QSystemLocale:

virtual QLocale fallbackLocale() const

Class QPointF:

qreal manhattanLength() const

Class QRegExp:

int captureCount() const

Class QSharedPointer:

QSharedPointer<X> objectCast() const

Class QSet:

bool contains(const QSet<T> & other) const

Class QWeakPointer:

T * data() const
QWeakPointer<T> operator=(const QObject * obj)

Class QXmlStreamReader:

QString readElementText(ReadElementTextBehaviour behaviour)
bool readNextStartElement()
void skipCurrentElement()

Class QDBusConnection:

bool connect(const QString & service, const QString & path, const QString & interface, const QString & name, const QStringList & argumentMatch, const QString & signature, QObject * receiver, const char * slot)
bool disconnect(const QString & service, const QString & path, const QString & interface, const QString & name, const QStringList & argumentMatch, const QString & signature, QObject * receiver, const char * slot)

Class QDBusPendingCall:

QDBusPendingCall fromCompletedCall(const QDBusMessage & msg)
QDBusPendingCall fromError(const QDBusError & error)

Class QWSKeyboardHandler:

KeycodeAction processKeycode(quint16 keycode, bool isPress, bool autoRepeat)

Class QScreen:

int colorCount()

Class QGraphicsItem:

bool acceptTouchEvents() const
bool filtersChildEvents() const
QGraphicsItem * focusItem() const
QGraphicsItem * focusProxy() const
QGraphicsEffect * graphicsEffect() const
Qt::InputMethodHints inputMethodHints() const
bool isActive() const
bool isBlockedByModalPanel(QGraphicsItem ** blockingPanel = 0) const
bool isPanel() const
QGraphicsItem * panel() const
PanelModality panelModality() const
QGraphicsObject * parentObject() const
qreal rotation() const
qreal scale() const
void setAcceptTouchEvents(bool enabled)
void setActive(bool active)
void setFiltersChildEvents(bool enabled)
void setFocusProxy(QGraphicsItem * item)
void setGraphicsEffect(QGraphicsEffect * effect)
void setInputMethodHints(Qt::InputMethodHints hints)
void setPanelModality(PanelModality panelModality)
void setRotation(qreal angle)
void setScale(qreal factor)
void setTransformOriginPoint(const QPointF & origin)
void setTransformOriginPoint(qreal x, qreal y)
void setTransformations(const QList<QGraphicsTransform *> & transformations)
void setX(qreal x)
void setY(qreal y)
void stackBefore(const QGraphicsItem * sibling)
QGraphicsObject * toGraphicsObject()
const QGraphicsObject * toGraphicsObject() const
QPointF transformOriginPoint() const
QList<QGraphicsTransform *> transformations() const

Class QGraphicsLayoutItem:

bool ownedByLayout() const
void setOwnedByLayout(bool ownership)

Class QGraphicsLayout:

void addChildLayoutItem(QGraphicsLayoutItem * layoutItem)

Class QGraphicsScene:

QGraphicsItem * activePanel() const
bool isActive() const
QGraphicsItem * itemAt(const QPointF & position, const QTransform & deviceTransform) const
QGraphicsItem * itemAt(qreal x, qreal y, const QTransform & deviceTransform) const
QList<QGraphicsItem *> items(const QPointF & pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform & deviceTransform = QTransform()) const
QList<QGraphicsItem *> items(const QRectF & rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform & deviceTransform = QTransform()) const
QList<QGraphicsItem *> items(const QPolygonF & polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform & deviceTransform = QTransform()) const
QList<QGraphicsItem *> items(const QPainterPath & path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform & deviceTransform = QTransform()) const
QList<QGraphicsItem *> items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform & deviceTransform = QTransform()) const
bool sendEvent(QGraphicsItem * item, QEvent * event)
void setActivePanel(QGraphicsItem * item)
void setSelectionArea(const QPainterPath & path, const QTransform & deviceTransform)
void setSelectionArea(const QPainterPath & path, Qt::ItemSelectionMode mode, const QTransform & deviceTransform)

Class QGraphicsView:

bool isTransformed() const

Class QIcon:

QIcon fromTheme(const QString & name, const QIcon & fallback = QIcon())
bool hasThemeIcon(const QString & name)
void setThemeName(const QString & name)
void setThemeSearchPaths(const QStringList & paths)
QString themeName()
QStringList themeSearchPaths()

Class QImage:

int byteCount() const
int colorCount() const
void setColorCount(int colorCount)

Class QPixmap:

QPixmap fromSymbianCFbsBitmap(CFbsBitmap * bitmap)
QPixmap fromSymbianRSgImage(RSgImage * sgImage)
QPixmap fromWinHICON(HICON icon)
void scroll(int dx, int dy, int x, int y, int width, int height, QRegion * exposed = 0)
void scroll(int dx, int dy, const QRect & rect, QRegion * exposed = 0)
CFbsBitmap * toSymbianCFbsBitmap() const
RSgImage * toSymbianRSgImage() const
HICON toWinHICON() const

Class QPixmapCache:

bool find(const QString & key, QPixmap * pixmap)
bool find(const Key & key, QPixmap * pixmap)
Key insert(const QPixmap & pixmap)
void remove(const Key & key)
bool replace(const Key & key, const QPixmap & pixmap)

Class QInputContext:

virtual bool symbianFilterEvent(QWidget * keywidget, const QSymbianEvent * event)

Class QApplication:

Qt::NavigationMode navigationMode()
void setNavigationMode(Qt::NavigationMode mode)
virtual bool symbianEventFilter(const QSymbianEvent * event)
int symbianProcessEvent(const QSymbianEvent * event)

Class QApplicationPrivate:

int symbianHandleCommand(const QSymbianEvent * symbianEvent)
int symbianResourceChange(const QSymbianEvent * symbianEvent)

Class QDesktopWidget:

void screenCountChanged(int newCount)

Class QFileOpenEvent:

QUrl url() const

Class QLayout:

QMargins contentsMargins() const
void setContentsMargins(const QMargins & margins)

Class QWidget:

QMargins contentsMargins() const
void grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags = Qt::GestureFlags())
QGraphicsEffect * graphicsEffect() const
QWidget * previousInFocusChain() const
void setContentsMargins(const QMargins & margins)
void setGraphicsEffect(QGraphicsEffect * effect)
void ungrabGesture(Qt::GestureType gesture)

Class QColor:

QColor fromHsl(int h, int s, int l, int a = 255)
QColor fromHslF(qreal h, qreal s, qreal l, qreal a = 1.0)
void getHsl(int * h, int * s, int * l, int * a = 0) const
void getHslF(qreal * h, qreal * s, qreal * l, qreal * a = 0) const
int hslHue() const
qreal hslHueF() const
int hslSaturation() const
qreal hslSaturationF() const
int lightness() const
qreal lightnessF() const
void setHsl(int h, int s, int l, int a = 255)
void setHslF(qreal h, qreal s, qreal l, qreal a = 1.0)

Class QMatrix:

qreal determinant() const

Class QPainter:

Class QPainterPath:

void translate(qreal dx, qreal dy)
void translate(const QPointF & offset)
QPainterPath translated(qreal dx, qreal dy) const
QPainterPath translated(const QPointF & offset) const

Class QPolygon:

QPolygon translated(int dx, int dy) const
QPolygon translated(const QPoint & offset) const

Class QPolygonF:

QPolygonF translated(qreal dx, qreal dy) const
QPolygonF translated(const QPointF & offset) const

Class QRegion:

int rectCount() const

Class QStyle:

const QStyle * proxy() const

Class QStyleOptionGraphicsItem:

qreal levelOfDetailFromTransform(const QTransform & worldTransform)

Class QSyntaxHighlighter:

void rehighlightBlock(const QTextBlock & block)

Class QTextDocument:

int availableRedoSteps() const
int availableUndoSteps() const

Class QTextCursor:

bool atEnd() const

Class QTextLine:

qreal leading() const
bool leadingIncluded() const
void setLeadingIncluded(bool included)

Class QAbstractScrollArea:

void setViewportMargins(const QMargins & margins)

Class QLineEdit:

void setTextMargins(const QMargins & margins)
QMargins textMargins() const

Class QPrintPreviewWidget:

int pageCount() const

Class QToolBar:

void topLevelChanged(bool topLevel)

Class QNetworkCacheMetaData:

AttributesMap attributes() const
void setAttributes(const AttributesMap & attributes)

Class QNetworkAccessManager:

QNetworkReply * deleteResource(const QNetworkRequest & request)

Class QNetworkReply:

void ignoreSslErrors(const QList<QSslError> & errors)
bool isFinished() const
bool isRunning() const

Class QNetworkRequest:

QObject * originatingObject() const
void setOriginatingObject(QObject * object)

Class QAbstractSocket:

void setSocketOption(QAbstractSocket::SocketOption option, const QVariant & value)
QVariant socketOption(QAbstractSocket::SocketOption option)

Class QNetworkProxyFactory:

void setUseSystemConfiguration(bool enable)

Class QSslSocket:

void connectToHostEncrypted(const QString & hostName, quint16 port, const QString & sslPeerName, OpenMode mode = ReadWrite)
void ignoreSslErrors(const QList<QSslError> & errors)
void setSocketOption(QAbstractSocket::SocketOption option, const QVariant & value)
QVariant socketOption(QAbstractSocket::SocketOption option)

Class QGLContext:

bool areSharing(const QGLContext * context1, const QGLContext * context2)
GLuint bindTexture(const QImage & image, GLenum target, GLint format, BindOptions options)
GLuint bindTexture(const QPixmap & pixmap, GLenum target, GLint format, BindOptions options)

Class QGLWidget:

GLuint bindTexture(const QImage & image, GLenum target, GLint format, QGLContext::BindOptions options)
GLuint bindTexture(const QPixmap & pixmap, GLenum target, GLint format, QGLContext::BindOptions options)

Class QGLFramebufferObject:

void blitFramebuffer(QGLFramebufferObject * target, const QRect & targetRect, QGLFramebufferObject * source, const QRect & sourceRect, GLbitfield buffers = GL_COLOR_BUFFER_BIT, GLenum filter = GL_NEAREST)
bool hasOpenGLFramebufferBlit()

Class QScriptString:

quint32 toArrayIndex(bool * ok = 0) const

Class QScriptEngineDebugger:

DebuggerState state() const

Class QSqlDriver:

bool isIdentifierEscapedImplementation(const QString & identifier, IdentifierType type) const
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
QString stripDelimitersImplementation(const QString & identifier, IdentifierType type) const

Class QSqlDatabase:

QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)

Class QAbstractXmlNodeModel:

QSourceLocation sourceLocation(const QXmlNodeModelIndex & index) const

Class QXmlQuery:

bool setFocus(const QString & focus)

Class QHelpSearchEngine:

int hitCount() const

New Functions in Namespaces

bool qWaitForWindowShown(QWidget * window)
void setPreferredPaintEngine(QPaintEngine::Type engineType)

New Global Functions

QDataStream & operator<<(QDataStream & stream, const QWebHistory & history)
QDataStream & operator>>(QDataStream & stream, QWebHistory & history)
void qDrawBorderPixmap(QPainter * painter, const QRect & target, const QMargins & margins, const QPixmap & pixmap)
bool qFuzzyCompare(const QTransform & t1, const QTransform & t2)
bool qFuzzyCompare(const QMatrix & m1, const QMatrix & m2)
QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<T> & other)
QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> & other)
int qWebKitMajorVersion()
int qWebKitMinorVersion()
QString qWebKitVersion()
QString qtTrId(const char * id, int n = -1)

New Macros

New Enum Types

enum SocketOption { LowDelayOption, KeepAliveOption, MulticastTtlOption, MulticastLoopbackOption }
enum Priority { LowPriority, NormalPriority, HighPriority }
enum SoftKeyRole { NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey }
enum BindOption { NoBindOption, InvertedYBindOption, MipmapBindOption, PremultipliedAlphaBindOption, LinearFilteringBindOption, DefaultBindOption }
enum BlurHint { PerformanceHint, QualityHint, AnimationHint }
enum PanelModality { NonModal, PanelModal, SceneModal }
enum DebuggerState { RunningState, SuspendedState }
enum ErrorDomain { QtNetwork, Http, WebKit }
enum ReadElementTextBehaviour { ErrorOnUnexpectedElement, IncludeChildElements, SkipChildElements }
enum CoordinateSystem { DeviceCoordinates, LogicalCoordinates }
enum GestureFlag { DontStartGestureOnChildren, ReceivePartialGestures, IgnoredGesturesPropagateToParent }
enum GestureState { GestureStarted, GestureUpdated, GestureFinished, GestureCanceled }
enum GestureType { TapGesture, TapAndHoldGesture, PanGesture, PinchGesture, SwipeGesture, CustomGesture }
enum NavigationMode { NavigationModeNone, NavigationModeKeypadTabOrder, NavigationModeKeypadDirectional, NavigationModeCursorAuto, NavigationModeCursorForceVisible }
enum TileRule { StretchTile, RepeatTile, RoundTile }
enum TouchPointState { TouchPointPressed, TouchPointMoved, TouchPointStationary, TouchPointReleased }

New Typedefs

New Properties

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.