Qt 4.8 的新功能

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

Qt Quick 1.1

Qt Quick 1.1 引入 新变化 such as new properties and better performance.

  • Right-To-Left text support
  • 改进图像缓存
  • Text input improvements - Support for split-screen virtual keyboard
  • PinchArea Element - enables simple pinch gesture handling
  • New properties for QML 元素 .

Qt Platform Abstraction -- Lighthouse

QPA allows porting Qt to different windowing systems and devices easier. It provides a clean abstraction layer for porting QtGui to new window systems.

注意: QPA is considered an experimental feature in Qt 4.8. In Qt 5 it is a supported and complete feature.

Qt WebKit 2.2

新的 Qt WebKit release introduces bug fixes, performance improvements, and greater compiler compatibility.

线程化 OpenGL

Many Qt OpenGL functions are now thread-safe. Threads that cater to different situations are now available.

  • 缓冲交换线程
  • 纹理上传线程
  • QPainter thread

Qt 4.8 弃用项

As part of Open Governance, modules in Qt 4.8 will receive maintainers and receive different support levels.

Currently, a module has an activity classification, the Module Maturity Level . As well, a list of modules and their maturity level is in the Qt 开发者网络 .

对 Qt API 的补充

Qt 4.8 引入对 Qt API 的更改。

新的类、函数、宏、等

新类

C
CurrencyToStringArgument ( QSystemLocale )
D
QDBusUnixFileDescriptor
G
QGLFunctions
QGenericPlugin
QGenericPluginFactory
QGlyphRun
H
QHttpMultiPart
QHttpPart
I
QIdentityProxyModel
P
QPlatformCursor
QPlatformCursorImage
QPlatformFontDatabase
QPlatformWindowFormat
R
QRawFont
S
QScopedValueRollback
QSupportedWritingSystems

新成员函数

QGraphicsWebView :

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

QWebPage :

void viewportChangeRequested ()

QThreadPool :

bool waitForDone (int msecs )

QProcessEnvironment :

void insert (const QProcessEnvironment & e )
QStringList keys () const

QUrl :

bool isLocalFile () const
void swap (QUrl & other )
QString topLevelDomain () const

QAbstractItemModel :

void resetInternalData ()

QObject :

bool connect (const QObject * sender , const QMetaMethod & signal , const QObject * receiver , const QMetaMethod & method , Qt::ConnectionType type = Qt::AutoConnection)
bool disconnect (const QObject * sender , const QMetaMethod & signal , const QObject * receiver , const QMetaMethod & method )
int senderSignalIndex () const

QSharedMemory :

QString nativeKey () const
void setNativeKey (const QString & key )

QTranslator :

bool load (const QLocale & locale , const QString & filename , const QString & prefix = QString(), const QString & directory = QString(), const QString & suffix = QString())

QVariant :

void swap (QVariant & other )

QUuid :

QUuid fromRfc4122 (const QByteArray & bytes )
QByteArray toByteArray () const
QByteArray toRfc4122 () const

QBitArray :

void swap (QBitArray & other )

QByteArray :

void swap (QByteArray & other )

QContiguousCache :

void swap (QContiguousCache<T> & other )

QChar :

UnicodeVersion currentUnicodeVersion ()

QElapsedTimer :

qint64 nsecsElapsed () const

QHash :

void swap (QHash<Key, T> & other )

QMultiHash :

void swap (QMultiHash<Key, T> & other )

QLinkedList :

void swap (QLinkedList<T> & other )

QList :

void swap (QList<T> & other )

QLocale :

QString bcp47Name () const
QString createSeparatedList (const QStringList & list ) const
QString currencySymbol (CurrencySymbolFormat format = CurrencySymbol) const
Qt::DayOfWeek firstDayOfWeek () const
QList<QLocale> matchingLocales (QLocale::Language 语言 , QLocale::Script script , QLocale::Country country )
QString nativeCountryName () const
QString nativeLanguageName () const
QString quoteString (const QString & str , QuotationStyle style = StandardQuotation) const
QString quoteString (const QStringRef & str , QuotationStyle style = StandardQuotation) const
Script script () const
QString scriptToString (Script script )
QString toCurrencyString (qlonglong value , const QString & symbol = QString()) const
QString toCurrencyString (qulonglong value , const QString & symbol = QString()) const
QString toCurrencyString (short value , const QString & symbol = QString()) const
QString toCurrencyString (ushort value , const QString & symbol = QString()) const
QString toCurrencyString (int value , const QString & symbol = QString()) const
QString toCurrencyString (uint value , const QString & symbol = QString()) const
QString toCurrencyString (double value , const QString & symbol = QString()) const
QString toCurrencyString (float value , const QString & symbol = QString()) const
QString toLower (const QString & str ) const
QString toUpper (const QString & str ) const
QStringList uiLanguages () const
QList<Qt::DayOfWeek> weekdays () const

QMap :

void swap (QMap<Key, T> & other )

QQueue :

void swap (QQueue<T> & other )

QPoint :

QPoint & operator*= (float factor )
QPoint & operator*= (double factor )
QPoint & operator*= (int factor )

QMultiMap :

void swap (QMultiMap<Key, T> & other )

QRegExp :

void swap (QRegExp & other )

QSet :

void swap (QSet<T> & other )

QString :

bool contains (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int count (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool endsWith (const QStringRef & s , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int indexOf (const QStringRef & str , int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int lastIndexOf (const QStringRef & str , int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool startsWith (const QStringRef & s , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
void swap (QString & other )

QStack :

void swap (QStack<T> & other )

QStringRef :

bool contains (const QString & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool contains (QChar ch , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool contains (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int count (const QString & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int count (QChar ch , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int count (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool endsWith (const QString & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool endsWith (QLatin1String str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool endsWith (QChar ch , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool endsWith (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int indexOf (const QString & str , int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int indexOf (QChar ch , int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int indexOf (QLatin1String str , int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int indexOf (const QStringRef & str , int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int lastIndexOf (const QString & str , int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int lastIndexOf (QChar ch , int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int lastIndexOf (QLatin1String str , int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
int lastIndexOf (const QStringRef & str , int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool startsWith (const QString & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool startsWith (QLatin1String str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool startsWith (QChar ch , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool startsWith (const QStringRef & str , Qt::CaseSensitivity cs = Qt::CaseSensitive) const
QByteArray toAscii () const
QByteArray toLatin1 () const
QByteArray toLocal8Bit () const
QVector<uint> toUcs4 () const
QByteArray toUtf8 () const

QVarLengthArray :

iterator begin ()
const_iterator begin () const
const_iterator constBegin () const
const_iterator constEnd () const
iterator end ()
const_iterator end () const
iterator erase (iterator begin , iterator end )
iterator erase (iterator pos )
void insert (int i , const T & value )
void insert (int i , int count , const T & value )
iterator insert (iterator before , int count , const T & value )
iterator insert (iterator before , const T & value )
QVarLengthArray<T, Prealloc> & operator+= (const T & value )
QVarLengthArray<T, Prealloc> & operator<< (const T & value )
void prepend (const T & value )
void remove (int i )
void remove (int i , int count )
void replace (int i , const T & value )

QVector :

void swap (QVector<T> & other )

QXmlStreamWriter :

bool hasError () const

QDBusAbstractInterface :

void setTimeout (int timeout )
int timeout () const

QDBusConnection :

QDBusConnection connectToPeer (const QString & address , const QString & name )
ConnectionCapabilities connectionCapabilities () const
void disconnectFromPeer (const QString & name )
QByteArray localMachineId ()

QGraphicsGridLayout :

void removeItem (QGraphicsLayoutItem * item )

QGraphicsLayout :

bool instantInvalidatePropagation ()
void setInstantInvalidatePropagation (bool enable )

QBitmap :

void swap (QBitmap & other )

QIcon :

void swap (QIcon & other )

QImage :

void fill (const QColor & color )
void fill (Qt::GlobalColor color )
void swap (QImage & other )

QPicture :

void swap (QPicture & other )

QPixmap :

void swap (QPixmap & other )

QAbstractProxyModel :

virtual QModelIndex buddy (const QModelIndex & index ) const
virtual bool canFetchMore (const QModelIndex & parent ) const
virtual void fetchMore (const QModelIndex & parent )
virtual bool hasChildren (const QModelIndex & parent = QModelIndex()) const
virtual QMimeData * mimeData (const QModelIndexList & indexes ) const
virtual QStringList mimeTypes () const
virtual void sort (int column , Qt::SortOrder order = Qt::AscendingOrder)
virtual QSize span (const QModelIndex & index ) const
virtual Qt::DropActions supportedDropActions () const

QApplication :

Qt::KeyboardModifiers queryKeyboardModifiers ()

QFileOpenEvent :

bool openFile (QFile & file , QIODevice::OpenMode flags ) const

QKeySequence :

void swap (QKeySequence & other )

QSizePolicy :

bool hasWidthForHeight () const
void setWidthForHeight (bool dependent )

QWidget :

(preliminary) QPlatformWindow * platformWindow () const
QPlatformWindowFormat platformWindowFormat () const
(preliminary) void setPlatformWindow (QPlatformWindow * window )
void setPlatformWindowFormat (const QPlatformWindowFormat & format )

QBrush :

void swap (QBrush & other )

QRadialGradient :

qreal centerRadius () const
qreal focalRadius () const
void setCenterRadius (qreal radius )
void setFocalRadius (qreal radius )

QPainter :

QRectF clipBoundingRect () const
void drawGlyphRun (const QPointF & position , const QGlyphRun & glyphs )
void drawPixmapFragments (const QRectF * targetRects , const QRectF * sourceRects , int fragmentCount , const QPixmap & pixmap , PixmapFragmentHints hints = 0)

QPainterPath :

void swap (QPainterPath & other )

QPolygon :

void swap (QPolygon & other )

QPen :

void swap (QPen & other )

QPolygonF :

void swap (QPolygonF & other )

QPrinterInfo :

QPrinterInfo & operator= (const QPrinterInfo & other )

QRegion :

void swap (QRegion & other )

QFont :

HintingPreference hintingPreference () const
void setHintingPreference (HintingPreference hintingPreference )
void setStyleName (const QString & styleName )
QString styleName () const

QFontMetrics :

bool inFontUcs4 (uint character ) const

QFontInfo :

QString styleName () const

QFontMetricsF :

bool inFontUcs4 (uint ch ) const

QTextDocument :

Qt::CursorMoveStyle defaultCursorMoveStyle () const
void setDefaultCursorMoveStyle (Qt::CursorMoveStyle style )

QTextCharFormat :

QFont::HintingPreference fontHintingPreference () const
void setFontHintingPreference (QFont::HintingPreference hintingPreference )

QTextBlockFormat :

qreal lineHeight (qreal scriptLineHeight , qreal scaling ) const
qreal lineHeight () const
int lineHeightType () const
void setLineHeight (qreal height , int heightType )

QTextListFormat :

QString numberPrefix () const
QString numberSuffix () const
void setNumberPrefix (const QString & numberPrefix )
void setNumberSuffix (const QString & numberSuffix )

QTextLayout :

Qt::CursorMoveStyle cursorMoveStyle () const
QList<QGlyphRun> glyphRuns () const
int leftCursorPosition (int oldPos ) const
int rightCursorPosition (int oldPos ) const
void setCursorMoveStyle (Qt::CursorMoveStyle style )

QUndoCommand :

QString actionText () const

QCheckBox :

virtual QSize minimumSizeHint () const

QLineEdit :

Qt::CursorMoveStyle cursorMoveStyle () const
void setCursorMoveStyle (Qt::CursorMoveStyle style )

QRadioButton :

virtual QSize minimumSizeHint () const

QTabWidget :

virtual int heightForWidth (int width ) const

QNetworkAccessManager :

QNetworkReply * post (const QNetworkRequest & request , QHttpMultiPart * multiPart )
QNetworkReply * put (const QNetworkRequest & request , QHttpMultiPart * multiPart )

QNetworkReply :

void setFinished (bool finished )

QNetworkConfigurationManager :

void configurationRemoved (const QNetworkConfiguration & config )

QNetworkProxyQuery :

void setNetworkConfiguration (const QNetworkConfiguration & networkConfiguration )

QNativeSocketEngine :

virtual bool joinMulticastGroup (const QHostAddress & groupAddress , const QNetworkInterface & iface )
virtual bool leaveMulticastGroup (const QHostAddress & groupAddress , const QNetworkInterface & iface )
virtual QNetworkInterface multicastInterface () const
virtual bool setMulticastInterface (const QNetworkInterface & iface )

QUdpSocket :

bool joinMulticastGroup (const QHostAddress & groupAddress )
bool joinMulticastGroup (const QHostAddress & groupAddress , const QNetworkInterface & iface )
bool leaveMulticastGroup (const QHostAddress & groupAddress )
bool leaveMulticastGroup (const QHostAddress & groupAddress , const QNetworkInterface & iface )
QNetworkInterface multicastInterface () const
void setMulticastInterface (const QNetworkInterface & iface )

QSslConfiguration :

bool testSslOption (QSsl::SslOption option ) const

QSslSocket :

QString peerVerifyName () const
void setPeerVerifyName (const QString & hostName )

QGLFormat :

QGLFormat fromPlatformWindowFormat (const QPlatformWindowFormat & format )
QPlatformWindowFormat toPlatformWindowFormat (const QGLFormat & format )

QGLContext :

QGLContext * fromPlatformGLContext (QPlatformGLContext * platformContext )

QGLFramebufferObjectFormat :

bool mipmap () const
void setMipmap (bool enabled )

QSqlRelationalTableModel :

void setJoinMode (QSqlRelationalTableModel::JoinMode joinMode )

QHelpSearchQueryWidget :

void collapseExtendedSearch ()
void expandExtendedSearch ()
void setQuery (const QList<QHelpSearchQuery> & queryList )

新全局函数

bool operator!= (const QPlatformWindowFormat & a , const QPlatformWindowFormat & b )
bool operator!= (const QVarLengthArray<T, Prealloc1> & left , const QVarLengthArray<T, Prealloc2> & right )
const QPoint operator* (int factor , const QPoint & point )
const QPoint operator* (double factor , const QPoint & point )
const QPoint operator* (float factor , const QPoint & point )
const QPoint operator* (const QPoint & point , int factor )
const QPoint operator* (const QPoint & point , double factor )
const QPoint operator* (const QPoint & point , float factor )
bool operator== (const QPlatformWindowFormat & a , const QPlatformWindowFormat & b )
bool operator== (const QVarLengthArray<T, Prealloc1> & left , const QVarLengthArray<T, Prealloc2> & right )

新宏

Q_LIKELY ( expr )
Q_UNLIKELY ( expr )

新枚举类型

enum ConnectionCapability { UnixFileDescriptorPassing }
enum FileHandleFlag { AutoCloseHandle, DontCloseHandle }
enum HintingPreference { PreferDefaultHinting, PreferNoHinting, PreferVerticalHinting, PreferFullHinting }
enum CurrencySymbolFormat { CurrencyIsoCode, CurrencySymbol, CurrencyDisplayName }
enum QuotationStyle { StandardQuotation, AlternateQuotation }
enum Script { AnyScript, ArabicScript, CyrillicScript, DeseretScript, ..., TifinaghScript }
enum JoinMode { InnerJoin, LeftJoin }
enum LineHeightTypes { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight }
enum CursorMoveStyle { LogicalMoveStyle, VisualMoveStyle }

新的 Typedef

typedef const_reference
typedef reference
typedef value_type

新特性