Skip to content

PythonQt.QtCore.QMetaType

QMetaType

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

The class is used as a helper to marshall types in QVariant and in queued signals and slots connections. It associates a type name to a type so that it can be created and destructed dynamically at run-time. Declare new types with Q_DECLARE_METATYPE() to make them available to QVariant and other template-based functions. Call qRegisterMetaType() to make types available to non-template based functions, such as the queued signal and slot connections.

Any class or struct that has a public default constructor, a public copy constructor, and a public destructor can be registered.

The following code allocates and destructs an instance of MyClass:

int id = QMetaType::type("MyClass");
if (id != QMetaType::UnknownType) {
    void *myClassPtr = QMetaType::create(id);
    ...
    QMetaType::destroy(id, myClassPtr);
    myClassPtr = 0;
}

If we want the stream operators operator<<() and operator>>() to work on QVariant objects that store custom types, the custom type must provide operator<<() and operator>>() operators.

Source: https://doc.qt.io/archives/qt-5.15/qmetatype.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
IsEnumeration attribute Any
IsGadget attribute Any
MovableType attribute Any
NeedsConstruction attribute Any
NeedsDestruction attribute Any
PointerToQObject attribute Any
SharedPointerToQObject attribute Any
TrackingPointerToQObject attribute Any
TypeFlag attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
TypeFlags attribute type Convert a number or string to an integer, or return 0 if no arguments are given.
WasDeclaredAsMetaType attribute Any
WeakPointerToQObject attribute Any
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
compare function (self, lhs: Any, rhs: Any, typeId: Any, result: Any) -> bool X.compare(lhs, rhs, typeId, result) -> bool
construct function (self, type: Any, where: Any, copy: Any) -> Any X.construct(type, where, copy)
convert function (self, *args: Any, **kwargs: Any) -> Any X.convert(from, fromTypeId, to, toTypeId) -> bool
create function (self, copy: Any) -> Any Returns a copy of copy, assuming it is of type type.
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
destroy function (self, type: Any, data: Any) -> Any X.destroy(type, data)
destruct function (self, type: Any, where: Any) -> Any X.destruct(type, where)
equals function (self, lhs: Any, rhs: Any, typeId: Any, result: Any) -> bool X.equals(lhs, rhs, typeId, result) -> bool
flags function (self) -> Any Returns flags of the type for which this [QMetaType](https://doc.qt.io/archives/qt-5.15/qmetatype.html) instance was constructed.
hasRegisteredComparators function (self, typeId: Any) -> bool X.hasRegisteredComparators(typeId) -> bool
hasRegisteredConverterFunction function (self, fromTypeId: Any, toTypeId: Any) -> bool X.hasRegisteredConverterFunction(fromTypeId, toTypeId) -> bool
hasRegisteredDebugStreamOperator function (self, typeId: Any) -> bool X.hasRegisteredDebugStreamOperator(typeId) -> bool
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isRegistered function (self) -> bool X.isRegistered() -> bool
isValid function (self) -> bool X.isValid() -> bool
load function (self, stream: Any, type: Any, data: Any) -> bool X.load(stream, type, data) -> bool
metaObject function (self) -> Any X.metaObject() -> PythonQt.QtCore.QMetaObject
metaObjectForType function (self, type: Any) -> Any X.metaObjectForType(type) -> PythonQt.QtCore.QMetaObject
registerNormalizedTypedef function (self, normalizedTypeName: Any, aliasId: Any) -> int X.registerNormalizedTypedef(normalizedTypeName, aliasId) -> int
registerTypedef function (self, typeName: Any, aliasId: Any) -> int X.registerTypedef(typeName, aliasId) -> int
save function (self, stream: Any, type: Any, data: Any) -> bool X.save(stream, type, data) -> bool
sizeOf function (self) -> int X.sizeOf() -> int
type function (self, typeName: Any) -> int X.type(typeName) -> int
typeFlags function (self, type: Any) -> Any Returns flags of the given type.
typeName function (self, type: Any) -> int X.typeName(type) -> int
unregisterType function (self, type: Any) -> bool X.unregisterType(type) -> bool