What's New in Qt 4.7

Qt 4.7 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 Qt 4 的新功能 页面。

Declarative UI Development with Qt Quick

Qt 4.7 introduces Qt Quick , the Qt UI Creation Kit. that enables the creation of dynamic user interfaces, easier and more effective than possible with existing UI technologies. This UI Creation Kit consists of three technologies:

  • QML is a declarative language oriented on JavaScript that utilizes Qt's Meta-Object capabilities to enable designers and developers to collaborate tightly and create animated and fluid user experiences, using existing knowledge in script language and design.
  • Qt Declarative is a C++ library that provides the underlying engine, which translates the declarative description of the UI in QML into items on a QGraphicsScene . The library also provides APIs to bind custom C++ types and elements to QML, and to connect the QML UI with the underlying application logic written in C++.
  • Qt Creator has been improved to support interactive editing of QML UIs through drag-and-drop. The text editor supports the QML syntax and provides authoring assistance such as auto-completion, error lookup, help lookup and easy preview of QML UI's. The Qt Quick features in Qt Creator will be released with Qt Creator 2.1

Network Bearer Management

Bearer Management controls the connectivity state of the system. The new Bearer Management API in the QtNetwork module allows the application to identify whether the system is online and how many interfaces there are, as well as start and stop interfaces, or roam transparently between access points.

QNetworkAccessManager uses this API for HTTP level roaming.

Feature Improvements in QtWebKit

The QGraphicsWebView class has a new tiled backing store, which improves scrolling and zooming performance. You can even create animated zoom-in or zoom-out effects (see QWebSettings::TiledBackingStoreEnabled ).

On mobile platforms, it is often useful to avoid displaying separate scrollbars for iframes and framesets. If you switch on frame flattening, QtWebKit will resize frames to fit their content to avoid separate scrollbars (see QWebSettings::FrameFlatteningEnabled ).

Qt 4.7 adds support for accelerated compositing, which enhances the performance of CSS animations and transitions. Read more in this blog .

For hybrid QtWebKit and C++ projects, Qt 4.7 has added support for transporting QPixmap s between Qt C++ and WebKit . We have also improved the documentation for hybrid development. Read more here: The QtWebKit Bridge .

QtWebKit Performance Benchmarks

We have introduced a set of performance benchmarks for QtWebKit , and made numerous improvements in rendering performance, page loading performance, scrolling performance and CSS performance. Here are some examples from the benchmarks run on a 64-bit Linux workstation with the raster graphics system.

In a benchmark that measures the scrolling performance on popular websites, we found out that Qt 4.7.0 on this platform is 350% faster than Qt 4.6.0, thanks to several rendering related improvements.

Our page loading benchmark shows an improvement of 16% in Qt 4.7.0 from Qt 4.6.0. This is due to improvements in text layout speed, image decoding, resource loading and event handling.

Several CSS animation benchmarks indicate a speed improvement of 31% from Qt 4.6.0 to Qt 4.7.0. These benchmarks are effectively showing the improvement we get from accelerated compositing (see above).

除了 QtWebKit module, performance has been a focus area in Qt 4.7 throughout the Qt framework. Here are a couple of examples about performance related feature improvements.

On Mac OS X, Qt now uses a different widget implementation (called "alien widgets"), which improves the responsiveness of applications that have complex user interfaces with several widgets.

Qt 4.7 introduces the QStaticText class, which can be used to improve text rendering performance. More info is available from this blog .

The QPainter class has a new API for rendering pixmap fragments ( QPainter::drawPixmapFragments ), which can improve the rendering performance of applications that need to render pixmap fragments .

Qt 4.7 has an updated version of the JavaScriptCore engine for the QtScript module, which improves JavaScript execution performance.

新的类、函数、宏、等

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

新类

A
AudioDataOutput ( Phonon )
D
QDeclarativeComponent
QDeclarativeContext
QDeclarativeEngine
QDeclarativeError
QDeclarativeExpression
QDeclarativeExtensionPlugin
QDeclarativeImageProvider
QDeclarativeItem
QDeclarativeListProperty
QDeclarativeNetworkAccessManagerFactory
QDeclarativeParserStatus
QDeclarativeProperty
QDeclarativePropertyMap
QDeclarativeScriptString
QDeclarativeView
E
QElapsedTimer
G
QGLBuffer
N
QNetworkConfiguration
QNetworkConfigurationManager
QNetworkSession
P
PixmapFragment ( QPainter )
S
QScriptProgram
QStaticText
V
VideoWidgetInterface44 ( Phonon )
ViewportAttributes ( QWebPage )

新成员函数

VideoWidget :

QImage snapshot () const

QWebFrame :

void pageChanged ()
void scrollToAnchor (const QString & anchor )

QTextCodec :

QTextDecoder * makeDecoder (ConversionFlags flags ) const
QTextEncoder * makeEncoder (ConversionFlags flags ) const

QProcess :

QString nativeArguments () const
void setNativeArguments (const QString & arguments )

QVariant :

QEasingCurve toEasingCurve () const

QState :

QList<QAbstractTransition *> transitions () const

QByteArray :

QByteArray & replace (int pos , int len , const char * after , int alen )
QByteArray & setRawData (const char * data , uint size )

QChar :

bool isHighSurrogate (uint ucs4 )
bool isLowSurrogate (uint ucs4 )
bool requiresSurrogates (uint ucs4 )

QDateTime :

QDateTime currentDateTimeUtc ()
qint64 currentMSecsSinceEpoch ()
QDateTime fromMSecsSinceEpoch (qint64 msecs )
qint64 msecsTo (const QDateTime & other ) const
void setMSecsSinceEpoch (qint64 msecs )
qint64 toMSecsSinceEpoch () const

QList :

void reserve (int alloc )

QLocale :

Qt::LayoutDirection textDirection () const

QString :

QString & setRawData (const QChar * unicode , int size )

QDBusMessage :

bool autoStartService () const
void setAutoStartService (bool enable )

QFileSystemModel :

void directoryLoaded (const QString & path )

QWizard :

void pageAdded (int id )
void pageRemoved (int id )
void setSideWidget (QWidget * widget )
QWidget * sideWidget () const

QGraphicsItem :

void updateMicroFocus ()

QGraphicsObject :

void updateMicroFocus ()

QGraphicsScale :

void xScaleChanged ()
void yScaleChanged ()
void zScaleChanged ()

QIcon :

QString name () const

QIconEngineV2 :

QString iconName ()

QImage :

int bitPlaneCount () const
const uchar * constBits () const
const uchar * constScanLine (int i ) const

QPixmap :

bool convertFromImage (const QImage & image , Qt::ImageConversionFlags flags = Qt::AutoColor)

QItemSelectionRange :

bool isEmpty () const

QColor :

bool isValidColor (const QString & name )

QPainter :

void drawPixmapFragments (const PixmapFragment * fragments , int fragmentCount , const QPixmap & pixmap , PixmapFragmentHints hints = 0)
void drawStaticText (const QPointF & topLeftPosition , const QStaticText & staticText )
void drawStaticText (const QPoint & topLeftPosition , const QStaticText & staticText )
void drawStaticText (int left , int top , const QStaticText & staticText )

PixmapFragment :

PixmapFragment create (const QPointF & pos , const QRectF & sourceRect , qreal scaleX = 1, qreal scaleY = 1, qreal rotation = 0, qreal opacity = 1)

QPrinter :

int copyCount () const
void setCopyCount (int count )
bool supportsMultipleCopies () const

QTextDocument :

void clearUndoRedoStacks (Stacks stacksToClear = UndoAndRedoStacks)

QTextCursor :

bool keepPositionOnInsert () const
int positionInBlock () const
void setKeepPositionOnInsert (bool b )
void setVerticalMovementX (int x )
int verticalMovementX () const

QTextLine :

qreal horizontalAdvance () const

QTextBlock :

Qt::LayoutDirection textDirection () const

QLabel :

int selectionStart () const
void setSelection (int start , int length )

QPlainTextEdit :

QString anchorAt (const QPoint & pos ) const

QToolBar :

void visibilityChanged (bool visible )

QAudioDeviceInfo :

QList<int> supportedChannelCounts () const
QList<int> supportedSampleRates () const

QAudioFormat :

int channelCount () const
int sampleRate () const
void setChannelCount (int channels )
void setSampleRate (int samplerate )

QNetworkAccessManager :

QNetworkConfiguration activeConfiguration () const
QNetworkConfiguration configuration () const
NetworkAccessibility networkAccessible () const
QNetworkReply * sendCustomRequest (const QNetworkRequest & request , const QByteArray & verb , QIODevice * data = 0)
void setConfiguration (const QNetworkConfiguration & config )
void setNetworkAccessible (NetworkAccessibility accessible )

QNetworkRequest :

优先级 priority () const
void setPriority (Priority priority )

QAuthenticator :

QVariant option (const QString & opt ) const
QVariantHash options () const
void setOption (const QString & opt , const QVariant & value )

QTcpServer :

void addPendingConnection (QTcpSocket * socket )

QGLFormat :

int majorVersion () const
int minorVersion () const
OpenGLContextProfile profile () const
void setProfile (OpenGLContextProfile profile )
void setVersion (int major , int minor )

QGLShader :

bool hasOpenGLShaders (ShaderType type , const QGLContext * context = 0)

QGLShaderProgram :

GLenum geometryInputType () const
GLenum geometryOutputType () const
int geometryOutputVertexCount () const
int maxGeometryOutputVertices () const
void setAttributeArray (int location , GLenum type , const void * , int tupleSize , int stride = 0)
void setAttributeArray (const char * name , GLenum type , const void * , int tupleSize , int stride = 0)
void setAttributeBuffer (int location , GLenum type , int offset , int tupleSize , int stride = 0)
void setAttributeBuffer (const char * name , GLenum type , int offset , int tupleSize , int stride = 0)
void setGeometryOutputType (GLenum outputType )
void setGeometryOutputVertexCount (int count )
void setUniformValue (int location , const GLfloat[2][2] value )
void setUniformValue (int location , const GLfloat[3][3] value )
void setUniformValue (const char * name , const GLfloat[2][2] value )
void setUniformValue (const char * name , const GLfloat[3][3] value )

QScriptEngine :

QScriptValue evaluate (const QScriptProgram & program )
void reportAdditionalMemoryCost (int size )

名称空间中的新函数

const char * benchmarkMetricName (QBenchmarkMetric metric )
const char * benchmarkMetricUnit (QBenchmarkMetric metric )
void setBenchmarkResult (qreal result , QBenchmarkMetric metric )

新全局函数

uint qHash (const QUrl & url )

新枚举类型

enum OpenGLContextProfile { NoProfile, CoreProfile, CompatibilityProfile }
enum Operation { HeadOperation, GetOperation, PutOperation, PostOperation, DeleteOperation, CustomOperation }
enum 属性 { HttpStatusCodeAttribute, HttpReasonPhraseAttribute, RedirectionTargetAttribute, ConnectionEncryptedAttribute, ..., UserMax }
enum LoadControl { Automatic, Manual }
enum Priority { HighPriority, NormalPriority, LowPriority }
enum PixmapFragmentHint { OpaqueHint }
enum QBenchmarkMetric { FramesPerSecond, BitsPerSecond, BytesPerSecond, WalltimeMilliseconds, ..., Events }

新的 Typedef

typedef VideoWidgetInterfaceLatest
typedef const_iterator
typedef const_pointer
typedef const_reference
typedef difference_type
typedef iterator
typedef pointer
typedef reference
typedef size_type
typedef value_type

新特性

新 QML 类型

A
AnchorAnimation
AnimatedImage
Animation
B
Behavior
Binding
BorderImage
C
ColorAnimation
Column
Component
Connections
F
Flickable
Flipable
Flow
FocusPanel
FocusScope
FontLoader
G
Gradient
GradientStop
Grid
GridView
I
Image
Item
K
KeyEvent
KeyNavigation
Keys
L
LayoutItem
ListElement
ListModel
ListView
Loader
M
MouseArea
MouseEvent
N
NumberAnimation
P
ParallelAnimation
ParentAnimation
ParticleMotionGravity
ParticleMotionLinear
ParticleMotionWander
粒子
路径
PathAttribute
PathCubic
PathElement
PathLine
PathPercent
PathQuad
PathView
PauseAnimation
PropertyAction
PropertyAnimation
PropertyChanges
Q
QtObject
R
Rectangle
Repeater
Rotation
RotationAnimation
Row
S
Scale
ScriptAction
SequentialAnimation
SmoothedAnimation
SpringAnimation
State
StateGroup
SystemPalette
T
Text
TextEdit
TextInput
Timer
Transform
Transition
Translate
V
Vector3dAnimation
VisualItemModel
W
WebView
X
XmlListModel
XmlRole