类型转换

Qt 的许多基本数据类型,例如QString 、QPoint 或QImage ,都提供了与原生等效类型之间的相互转换。

以下列表罗列了所有可用的类型转换:

QByteArray::fromCFData()

QByteArray::fromEcmaUint8Array()

QByteArray::fromNSData()

构建一个新的 QByteArray,其中包含 NSData 数据的副本

QByteArray::fromRawCFData()

创建一个使用 CFData 数据字节的 QByteArray

QByteArray::fromRawNSData()

构建一个使用 NSData 数据字节的 QByteArray

QDateTime::fromCFDate()

创建一个新的 QDateTime,其中包含 CFDate 日期的副本

QDateTime::fromNSDate()

创建一个新的 QDateTime,其中包含 NSDate 日期的副本

QImage::fromHBITMAP()

返回一个与给定的 hbitmap 等效的 QImage

QImage::fromHICON()

返回一个与给定的图标等效的 QImage

QPointF::fromCGPoint()

根据 CGPoint 点创建一个 QRectF

QRectF::fromCGRect()

根据 CGRect rect 创建一个 QRectF

QRectF::fromDOMRect()

QSizeF::fromCGSize()

根据 size 创建一个 QSizeF

QString::fromCFString()

构建一个新的 QString,其中包含字符串 CFString 的副本

QString::fromEcmaString()

QString::fromNSString()

构建一个新的 QString,其中包含字符串 NSString 的副本

QTimeZone::fromCFTimeZone()

构建一个新的 QTimeZone,其中包含 CFTimeZone timeZone 的副本

QTimeZone::fromNSTimeZone()

构建一个新的 QTimeZone,其中包含 NSTimeZone timeZone 的副本

QUrl::fromCFURL()

构建一个包含 CFURL url 副本的 QUrl

QUrl::fromNSURL()

创建一个包含 NSURL url 副本的 QUrl

QUuid::fromCFUUID()

创建一个新的 QUuid,其中包含 uuid CFUUID 的副本

QUuid::fromNSUUID()

构建一个新的 QUuid,其中包含 uuid NSUUID 的副本

QByteArray::toEcmaUint8Array()

QByteArray::toCFData()

从 QByteArray 创建一个 CFData

QByteArray::toRawCFData()

构建一个使用 QByteArray 中字节的 CFData

QDateTime::toCFDate()

根据 QDateTime 创建一个 CFDate

QStringView::toCFString()

根据此 QStringView 创建一个 CFString

QString::toCFString()

根据 QString 创建一个 CFString

QTimeZone::toCFTimeZone()

根据 QTimeZone 创建 CFTimeZone

QUrl::toCFURL()

根据 QUrl 创建一个 CFURL

QUuid::toCFUUID()

根据 QUuid 创建 CFUUID

QImage::toCGImage()

QPointF::toCGPoint()

根据 QPointF 创建一个 CGPoint

QPoint::toCGPoint()

根据 QPoint 创建 CGPoint

QRectF::toCGRect()

根据 QRectF 创建 CGRect

QRect::toCGRect()

根据 QRect 创建 CGRect

QSizeF::toCGSize()

根据 QSizeF 创建 CGSize

QSize::toCGSize()

根据 QSize 创建 CGSize

QImage::toHBITMAP()

创建与 QImage 等效的 HBITMAP

QImage::toHICON()

创建与 QPixmap 等效的 HICON,并应用掩码 mask

QByteArray::toNSData()

根据 QByteArray 创建 NSData

QByteArray::toRawNSData()

构建一个使用 QByteArray 中字节的 NSData

QDateTime::toNSDate()

根据 QDateTime 创建 NSDate

QString::toNSString()

从 QString 创建一个 NSString

QStringView::toNSString()

根据此 QStringView 创建一个 NSString

QTimeZone::toNSTimeZone()

根据 QTimeZone 创建 NSTimeZone

QUrl::toNSURL()

根据 QUrl 创建一个 NSURL

QUuid::toNSUUID()

根据 QUuid 创建 NSUUID

QRectF::toDOMRect()

QString::toEcmaString()

© 2026 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.