以表格方式列出支持那些类型。
Qml类型与Qt类型对照表Qml类型 | Qt类型 |
---|
bool | bool | int | unsigned int, int | double | double | real | float, qreal | string | QString | url | QUrl | color | QColor | font | QFont | date | QDateTime | point | QPoint, QPointF | size | QSize, QSizeF | rect | QRect, QRectF | matrix4x4 | QMatrix4x4 | quaternion | QQuaternion | vector2d,
vector3d,
vector4d
| QVector2D,
QVector3D,
QVector4D
| var,variant | QVariant | enumeration | 使用Q_ENUM()或Q_ENUMS()声明的枚举 |
js类型与Qt类型对照表js类型 | Qt类型 |
---|
数组 | QVariantList | 对象 | QVariantMap | Date | QDateTime, QTime | ArrayBuffer | QByteArray |
js数组与Qt容器支持的类型
QList<int>
QList<qreal>
QList<bool>
QList<QString> ,QStringList
QVector<QString>
std::vector<QString>
QList<QUrl>
QVector<QUrl>
std::vector<QUrl>
QVector<int>
QVector<qreal>
QVector<bool>
std::vector<int>
std::vector<qreal>
std::vector<bool>
通过使用Q_DECLARE_METATYPE宏还可以自定义的QList, QVector, QQueue, QStack, QSet, QLinkedList, std::list, std::vector转换到js数组中中。
其他类型方法Qml实现 | Qt方法 |
---|
“10,10,100x100” | Qt.rect(10, 10, 100, 100) | “0,10” | Qt.point(0, 10) | “100x100” | Qt.size(100, 100) | date | Qt.formatDate(“2019-01-01 00:00”), Qt.formatDateTime(“2019-01-01 00:00”) |
类型 | 值表示 |
---|
bool | true | int | 10 | double | 1.0 | real | 1.0 | string | “This is string.”,String(“This is string.”) | color | Qt.rgba(0.1, 0.1, 0.1, 0.1) | rect | Qt.rect(100, 100, 100, 100) | point | Qt.point(100, 100) | size | Qt.size(100, 100) | vector3d | Qt.vector3d(100, 100, 100) | 数组 | [1, “2”, (function() { return “3”; })] | 对象 | { “value1”: 1, “value2”: 2 } | 函数 | (function() { return “OK”; }) |
关于更多 ---------------------------------------------------------------------------------------------------------------------- 我们尊重原创,也注重分享,文章来源于微信公众号:Qt君,建议关注公众号查看原文。如若侵权请联系qter@qter.org。 ----------------------------------------------------------------------------------------------------------------------
|