QMetaType Class Reference

[QtCore module]

该QMetaType类管理的元对象系统中命名类型。More…

Types

  • enum Type { Void, Bool, Int, UInt, ..., User }

Methods

  • __init__ (self)
  • __init__ (self, QMetaType)

Static Methods

  • bool isRegistered (int type)
  • int type (str typeName)
  • str typeName (int type)

Detailed Description

该QMetaType类管理的元对象系统中命名类型。

这个类被用作辅助马歇尔类型QVariant而在排队的信号和槽的连接。它关联一个类型名的类型,以便它可以被创建并在运行时动态地破坏。声明新类型的Q_DECLARE_METATYPE( ) ,使他们能够提供QVariant与其他基于模板的功能。通话qRegisterMetaType()以提供给非基于模板的功能,诸如排队的信号和槽的连接类型。

任何类或结构有一个公共的默认构造函数,公共拷贝构造函数和析构函数市民可以注册。

下面的代码分配和解构的一个实例MyClass

  1. int id = QMetaType.type("MyClass");
  2. if (id != 0) {
  3. void *myClassPtr = QMetaType.construct(id);
  4. ...
  5. QMetaType.destroy(id, myClassPtr);
  6. myClassPtr = 0;
  7. }

如果我们想在流运算符operator<<()operator>>()工作在QVariant存储自定义类型的对象,自定义类型必须提供operator<<()operator>>()运营商。


Type Documentation

  1. QMetaType.Type

这些是由所支持的内置类型QMetaType

Constant Value Description
QMetaType.Void 0 void
QMetaType.Bool 1 bool
QMetaType.Int 2 int
QMetaType.UInt 3 unsigned int
QMetaType.Double 6 double
QMetaType.QChar 7 QChar
QMetaType.QString 10 QString的
QMetaType.QByteArray 12 QByteArray中
QMetaType.VoidStar 128 void *
QMetaType.Long 129 long
QMetaType.LongLong 4 的LongLong
QMetaType.Short 130 short
QMetaType.Char 131 char
QMetaType.ULong 132 unsigned long
QMetaType.ULongLong 5 ULONGLONG
QMetaType.UShort 133 unsigned short
QMetaType.UChar 134 unsigned char
QMetaType.Float 135 float
QMetaType.QObjectStar 136 QObject*
QMetaType.QWidgetStar 137 QWidget*
QMetaType.QVariant 138 的QVariant
QMetaType.QColorGroup 63 QColorGroup
QMetaType.QCursor 74 QCursor
QMetaType.QDate 14 的QDate
QMetaType.QSize 21 QSIZE
QMetaType.QTime 15 QTIME
QMetaType.QVariantList 9 QVariantList
QMetaType.QPolygon 71 QPolygon
QMetaType.QColor 67 而QColor
QMetaType.QSizeF 22 QSizeF
QMetaType.QRectF 20 QRectF
QMetaType.QLine 23 QLine
QMetaType.QTextLength 78 QTextLength
QMetaType.QStringList 11 QStringList中
QMetaType.QVariantMap 8 QVariantMap
QMetaType.QVariantHash 28 QVariantHash
QMetaType.QIcon 69 QIcon则
QMetaType.QPen 77 QPen
QMetaType.QLineF 24 QLineF
QMetaType.QTextFormat 79 QTextFormat
QMetaType.QRect 19 查阅QRect
QMetaType.QPoint 25 QPoint
QMetaType.QUrl 17 QUrl
QMetaType.QRegExp 27 QRegExp
QMetaType.QDateTime 16 QDateTime
QMetaType.QPointF 26 QPointF
QMetaType.QPalette 68 QPalette
QMetaType.QFont 64 QFont
QMetaType.QBrush 66 QBrush
QMetaType.QRegion 72 QRegion
QMetaType.QBitArray 13 QBitArray
QMetaType.QImage 70 QImage的
QMetaType.QKeySequence 76 QKeySequence
QMetaType.QSizePolicy 75 QSizePolicy
QMetaType.QPixmap 65 的QPixmap
QMetaType.QLocale 18 QLocale
QMetaType.QBitmap 73 QBitmap
QMetaType.QMatrix 80 系列QMatrix
QMetaType.QTransform 81 QTransform
QMetaType.QMatrix4x4 82 QMatrix4x4
QMetaType.QVector2D 83 QVector2D
QMetaType.QVector3D 84 QVector3D
QMetaType.QVector4D 85 QVector4D
QMetaType.QQuaternion 86 QQuaternion
QMetaType.QEasingCurve 29 QEasingCurve
QMetaType.User 256 用户类型基值

其他类型的可使用注册Q_DECLARE_METATYPE( ) 。

See also type()和typeName( ) 。


Method Documentation

  1. QMetaType.__init__ (self)
  1. QMetaType.__init__ (self, QMetaType)
  1. bool QMetaType.isRegistered (int type)

返回True如果一个ID的数据类型type注册,否则返回False 。

See also type( )typeName()和Type

  1. int QMetaType.type (str typeName)

返回的句柄调用类型typeName或0,如果不存在这样的类型。

See also isRegistered( )typeName()和Type

  1. str QMetaType.typeName (int type)

返回与给定关联的类型名称type,或者0 ,如果没有匹配的类型被发现。返回的指针不能被删除。

See also type( )isRegistered()和Type