[][src]Struct qt_core::QMetaType

#[repr(C)]pub struct QMetaType { /* fields omitted */ }

The QMetaType class manages named types in the meta-object system.

C++ class: QMetaType.

C++ documentation:

The QMetaType class manages named types in the meta-object system.

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.

Methods

impl QMetaType[src]

pub unsafe fn compare(
    lhs: *const c_void,
    rhs: *const c_void,
    type_id: c_int,
    result: *mut c_int
) -> bool
[src]

Compares the objects at lhs and rhs. Both objects need to be of type typeId. result is set to less than, equal to or greater than zero, if lhs is less than, equal to or greater than rhs. Returns true, if the comparison succeeded, otherwise false.

Calls C++ function: static bool QMetaType::compare(const void* lhs, const void* rhs, int typeId, int* result).

C++ documentation:

Compares the objects at lhs and rhs. Both objects need to be of type typeId. result is set to less than, equal to or greater than zero, if lhs is less than, equal to or greater than rhs. Returns true, if the comparison succeeded, otherwise false.

This function was introduced in Qt 5.2.

pub unsafe fn construct_3a(
    type_: c_int,
    where_: *mut c_void,
    copy: *const c_void
) -> *mut c_void
[src]

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Calls C++ function: static void* QMetaType::construct(int type, void* where, const void* copy).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for static void *QMetaType::construct(int type, const void *copy = Q_NULLPTR):

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Deprecated, use the static function QMetaType::create(int type, const void *copy) instead.

pub unsafe fn construct_2a(
    &self,
    where_: *mut c_void,
    copy: *const c_void
) -> *mut c_void
[src]

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Calls C++ function: void* QMetaType::construct(void* where, const void* copy = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for static void *QMetaType::construct(int type, const void *copy = Q_NULLPTR):

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Deprecated, use the static function QMetaType::create(int type, const void *copy) instead.

pub unsafe fn construct_1a(&self, where_: *mut c_void) -> *mut c_void[src]

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Calls C++ function: void* QMetaType::construct(void* where) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for static void *QMetaType::construct(int type, const void *copy = Q_NULLPTR):

Constructs a value of the given type which is a copy of copy. The default value for copy is 0.

Deprecated, use the static function QMetaType::create(int type, const void *copy) instead.

pub unsafe fn convert(
    from: *const c_void,
    from_type_id: c_int,
    to: *mut c_void,
    to_type_id: c_int
) -> bool
[src]

Converts the object at from from fromTypeId to the preallocated space at to typed toTypeId. Returns true, if the conversion succeeded, otherwise false.

Calls C++ function: static bool QMetaType::convert(const void* from, int fromTypeId, void* to, int toTypeId).

C++ documentation:

Converts the object at from from fromTypeId to the preallocated space at to typed toTypeId. Returns true, if the conversion succeeded, otherwise false.

This function was introduced in Qt 5.2.

pub unsafe fn create_int_void(type_: c_int, copy: *const c_void) -> *mut c_void[src]

Returns a copy of copy, assuming it is of type type. If copy is zero, creates a default constructed instance.

Calls C++ function: static void* QMetaType::create(int type, const void* copy = …).

C++ documentation:

Returns a copy of copy, assuming it is of type type. If copy is zero, creates a default constructed instance.

See also destroy(), isRegistered(), and Type.

pub unsafe fn create_void(&self, copy: *const c_void) -> *mut c_void[src]

Returns a copy of copy, assuming it is of the type that this QMetaType instance was created for. If copy is null, creates a default constructed instance.

Calls C++ function: void* QMetaType::create(const void* copy = …) const.

C++ documentation:

Returns a copy of copy, assuming it is of the type that this QMetaType instance was created for. If copy is null, creates a default constructed instance.

This function was introduced in Qt 5.0.

See also QMetaType::destroy().

pub unsafe fn create_int(type_: c_int) -> *mut c_void[src]

Returns a copy of copy, assuming it is of type type. If copy is zero, creates a default constructed instance.

Calls C++ function: static void* QMetaType::create(int type).

C++ documentation:

Returns a copy of copy, assuming it is of type type. If copy is zero, creates a default constructed instance.

See also destroy(), isRegistered(), and Type.

pub unsafe fn create(&self) -> *mut c_void[src]

Returns a copy of copy, assuming it is of the type that this QMetaType instance was created for. If copy is null, creates a default constructed instance.

Calls C++ function: void* QMetaType::create() const.

C++ documentation:

Returns a copy of copy, assuming it is of the type that this QMetaType instance was created for. If copy is null, creates a default constructed instance.

This function was introduced in Qt 5.0.

See also QMetaType::destroy().

pub unsafe fn debug_stream(
    dbg: impl CastInto<Ref<QDebug>>,
    rhs: *const c_void,
    type_id: c_int
) -> bool
[src]

Streams the object at rhs of type typeId to the debug stream dbg. Returns true on success, otherwise false.

Calls C++ function: static bool QMetaType::debugStream(QDebug& dbg, const void* rhs, int typeId).

C++ documentation:

Streams the object at rhs of type typeId to the debug stream dbg. Returns true on success, otherwise false.

This function was introduced in Qt 5.2.

pub unsafe fn destroy_2a(type_: c_int, data: *mut c_void)[src]

Destroys the data, assuming it is of the type given.

Calls C++ function: static void QMetaType::destroy(int type, void* data).

C++ documentation:

Destroys the data, assuming it is of the type given.

See also create(), isRegistered(), and Type.

pub unsafe fn destroy_1a(&self, data: *mut c_void)[src]

Destroys the data, assuming it is of the type that this QMetaType instance was created for.

Calls C++ function: void QMetaType::destroy(void* data) const.

C++ documentation:

Destroys the data, assuming it is of the type that this QMetaType instance was created for.

This function was introduced in Qt 5.0.

See also QMetaType::create().

pub unsafe fn destruct_2a(type_: c_int, where_: *mut c_void)[src]

Destructs the value of the given type, located at where.

Calls C++ function: static void QMetaType::destruct(int type, void* where).

C++ documentation:

Destructs the value of the given type, located at where.

Unlike destroy(), this function only invokes the type's destructor, it doesn't invoke the delete operator.

This function was introduced in Qt 5.0.

See also construct().

pub unsafe fn destruct_1a(&self, data: *mut c_void)[src]

Destructs the value, located at data, assuming that it is of the type for which this QMetaType instance was constructed for.

Calls C++ function: void QMetaType::destruct(void* data) const.

C++ documentation:

Destructs the value, located at data, assuming that it is of the type for which this QMetaType instance was constructed for.

Unlike destroy(), this function only invokes the type's destructor, it doesn't invoke the delete operator.

This function was introduced in Qt 5.0.

See also QMetaType::construct().

pub unsafe fn equals(
    lhs: *const c_void,
    rhs: *const c_void,
    type_id: c_int,
    result: *mut c_int
) -> bool
[src]

Compares the objects at lhs and rhs. Both objects need to be of type typeId. result is set to zero, if lhs equals to rhs. Returns true, if the comparison succeeded, otherwise false.

Calls C++ function: static bool QMetaType::equals(const void* lhs, const void* rhs, int typeId, int* result).

C++ documentation:

Compares the objects at lhs and rhs. Both objects need to be of type typeId. result is set to zero, if lhs equals to rhs. Returns true, if the comparison succeeded, otherwise false.

This function was introduced in Qt 5.5.

pub unsafe fn flags(&self) -> QFlags<TypeFlag>[src]

Returns flags of the type for which this QMetaType instance was constructed.

Calls C++ function: QFlags<QMetaType::TypeFlag> QMetaType::flags() const.

C++ documentation:

Returns flags of the type for which this QMetaType instance was constructed.

This function was introduced in Qt 5.0.

See also QMetaType::TypeFlags and QMetaType::typeFlags().

pub unsafe fn has_registered_comparators(type_id: c_int) -> bool[src]

Returns true, if the meta type system has registered comparators for type id typeId.

Calls C++ function: static bool QMetaType::hasRegisteredComparators(int typeId).

C++ documentation:

Returns true, if the meta type system has registered comparators for type id typeId.

This function was introduced in Qt 5.2.

pub unsafe fn has_registered_converter_function(
    from_type_id: c_int,
    to_type_id: c_int
) -> bool
[src]

Returns true, if the meta type system has a registered conversion from meta type id fromTypeId to toTypeId

Calls C++ function: static bool QMetaType::hasRegisteredConverterFunction(int fromTypeId, int toTypeId).

C++ documentation:

Returns true, if the meta type system has a registered conversion from meta type id fromTypeId to toTypeId

This function was introduced in Qt 5.2.

pub unsafe fn has_registered_debug_stream_operator(type_id: c_int) -> bool[src]

Returns true, if the meta type system has a registered debug stream operator for type id typeId.

Calls C++ function: static bool QMetaType::hasRegisteredDebugStreamOperator(int typeId).

C++ documentation:

Returns true, if the meta type system has a registered debug stream operator for type id typeId.

This function was introduced in Qt 5.2.

pub unsafe fn id(&self) -> c_int[src]

This is supported on cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Returns id type hold by this QMetatype instance.

Calls C++ function: int QMetaType::id() const.

C++ documentation:

Returns id type hold by this QMetatype instance.

This function was introduced in Qt 5.13.

pub unsafe fn is_registered_1a(type_: c_int) -> bool[src]

Returns true if the datatype with ID type is registered; otherwise returns false.

Calls C++ function: static bool QMetaType::isRegistered(int type).

C++ documentation:

Returns true if the datatype with ID type is registered; otherwise returns false.

See also type(), typeName(), and Type.

pub unsafe fn is_registered_0a(&self) -> bool[src]

Returns true if this QMetaType object contains valid information about a type, false otherwise.

Calls C++ function: bool QMetaType::isRegistered() const.

C++ documentation:

Returns true if this QMetaType object contains valid information about a type, false otherwise.

This function was introduced in Qt 5.0.

pub unsafe fn is_valid(&self) -> bool[src]

Returns true if this QMetaType object contains valid information about a type, false otherwise.

Calls C++ function: bool QMetaType::isValid() const.

C++ documentation:

Returns true if this QMetaType object contains valid information about a type, false otherwise.

This function was introduced in Qt 5.0.

pub unsafe fn load(
    stream: impl CastInto<Ref<QDataStream>>,
    type_: c_int,
    data: *mut c_void
) -> bool
[src]

Reads the object of the specified type from the given stream into data. Returns true if the object is loaded successfully; otherwise returns false.

Calls C++ function: static bool QMetaType::load(QDataStream& stream, int type, void* data).

C++ documentation:

Reads the object of the specified type from the given stream into data. Returns true if the object is loaded successfully; otherwise returns false.

The type must have been registered with qRegisterMetaType() and qRegisterMetaTypeStreamOperators() beforehand.

Normally, you should not need to call this function directly. Instead, use QVariant's operator>>(), which relies on load() to stream custom types.

See also save() and qRegisterMetaTypeStreamOperators().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

return a QMetaObject relative to this type.

Calls C++ function: const QMetaObject* QMetaType::metaObject() const.

C++ documentation:

return a QMetaObject relative to this type.

If the type is a pointer type to a subclass of QObject, flags() contains QMetaType::PointerToQObject and this function returns the corresponding QMetaObject. This can be used to in combinaison with QMetaObject::construct to create QObject of this type.

If the type is a Q_GADGET, flags() contains QMetaType::IsGadget, and this function returns its QMetaObject. This can be used to retrieve QMetaMethod and QMetaProperty and use them on a pointer of this type. (given by QVariant::data for example)

If the type is an enumeration, flags() contains QMetaType::IsEnumeration, and this function returns the QMetaObject of the enclosing object if the enum was registered as a Q_ENUM or 0 otherwise

This function was introduced in Qt 5.5.

See also QMetaType::metaObjectForType() and QMetaType::flags().

pub unsafe fn meta_object_for_type(type_: c_int) -> Ptr<QMetaObject>[src]

returns QMetaType::metaObject for type

Calls C++ function: static const QMetaObject* QMetaType::metaObjectForType(int type).

C++ documentation:

returns QMetaType::metaObject for type

This function was introduced in Qt 5.0.

See also metaObject().

pub unsafe fn new(type_: c_int) -> CppBox<QMetaType>[src]

Constructs a QMetaType object that contains all information about type typeId.

Calls C++ function: [constructor] void QMetaType::QMetaType(int type).

C++ documentation:

Constructs a QMetaType object that contains all information about type typeId.

This function was introduced in Qt 5.0.

pub unsafe fn register_normalized_type_q_byte_array_option_fn_option_fn_option_fn_option_fn_int_q_flags_type_flag_q_meta_object(
    normalized_type_name: impl CastInto<Ref<QByteArray>>,
    deleter: Option<extern "C" fn(_: *mut c_void)>,
    creator: Option<extern "C" fn(_: *const c_void) -> *mut c_void>,
    destructor: Option<extern "C" fn(_: *mut c_void)>,
    constructor: Option<extern "C" fn(_: *mut c_void, _: *const c_void) -> *mut c_void>,
    size: c_int,
    flags: QFlags<TypeFlag>,
    meta_object: impl CastInto<Ptr<QMetaObject>>
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerNormalizedType(const QByteArray& normalizedTypeName, void (*FN_PTR)(void *) deleter, void * (*FN_PTR)(void const *) creator, void (*FN_PTR)(void *) destructor, void * (*FN_PTR)(void *, void const *) constructor, int size, QFlags<QMetaType::TypeFlag> flags, const QMetaObject* metaObject).

pub unsafe fn register_normalized_type_q_byte_array_option_fn_option_fn_int_q_flags_type_flag_q_meta_object(
    normalized_type_name: impl CastInto<Ref<QByteArray>>,
    destructor: Option<extern "C" fn(_: *mut c_void)>,
    constructor: Option<extern "C" fn(_: *mut c_void, _: *const c_void) -> *mut c_void>,
    size: c_int,
    flags: QFlags<TypeFlag>,
    meta_object: impl CastInto<Ptr<QMetaObject>>
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerNormalizedType(const QByteArray& normalizedTypeName, void (*FN_PTR)(void *) destructor, void * (*FN_PTR)(void *, void const *) constructor, int size, QFlags<QMetaType::TypeFlag> flags, const QMetaObject* metaObject).

pub unsafe fn register_normalized_type_q_byte_array_option_fn_option_fn_int_q_flags_type_flag_q_meta_object2(
    normalized_type_name: impl CastInto<Ref<QByteArray>>,
    destructor: Option<extern "C" fn(_: c_int, _: *mut c_void)>,
    constructor: Option<extern "C" fn(_: c_int, _: *mut c_void, _: *const c_void) -> *mut c_void>,
    size: c_int,
    flags: QFlags<TypeFlag>,
    meta_object: impl CastInto<Ptr<QMetaObject>>
) -> c_int
[src]

This is supported on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: static int QMetaType::registerNormalizedType(const QByteArray& normalizedTypeName, void (*FN_PTR)(int, void *) destructor, void * (*FN_PTR)(int, void *, void const *) constructor, int size, QFlags<QMetaType::TypeFlag> flags, const QMetaObject* metaObject).

pub unsafe fn register_normalized_typedef(
    normalized_type_name: impl CastInto<Ref<QByteArray>>,
    alias_id: c_int
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerNormalizedTypedef(const QByteArray& normalizedTypeName, int aliasId).

pub unsafe fn register_type_3a(
    type_name: *const c_char,
    deleter: Option<extern "C" fn(_: *mut c_void)>,
    creator: Option<extern "C" fn(_: *const c_void) -> *mut c_void>
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerType(const char* typeName, void (*FN_PTR)(void *) deleter, void * (*FN_PTR)(void const *) creator).

pub unsafe fn register_type_8a(
    type_name: *const c_char,
    deleter: Option<extern "C" fn(_: *mut c_void)>,
    creator: Option<extern "C" fn(_: *const c_void) -> *mut c_void>,
    destructor: Option<extern "C" fn(_: *mut c_void)>,
    constructor: Option<extern "C" fn(_: *mut c_void, _: *const c_void) -> *mut c_void>,
    size: c_int,
    flags: QFlags<TypeFlag>,
    meta_object: impl CastInto<Ptr<QMetaObject>>
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerType(const char* typeName, void (*FN_PTR)(void *) deleter, void * (*FN_PTR)(void const *) creator, void (*FN_PTR)(void *) destructor, void * (*FN_PTR)(void *, void const *) constructor, int size, QFlags<QMetaType::TypeFlag> flags, const QMetaObject* metaObject).

pub unsafe fn register_type_6a(
    type_name: *const c_char,
    destructor: Option<extern "C" fn(_: c_int, _: *mut c_void)>,
    constructor: Option<extern "C" fn(_: c_int, _: *mut c_void, _: *const c_void) -> *mut c_void>,
    size: c_int,
    flags: QFlags<TypeFlag>,
    meta_object: impl CastInto<Ptr<QMetaObject>>
) -> c_int
[src]

This is supported on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: static int QMetaType::registerType(const char* typeName, void (*FN_PTR)(int, void *) destructor, void * (*FN_PTR)(int, void *, void const *) constructor, int size, QFlags<QMetaType::TypeFlag> flags, const QMetaObject* metaObject).

pub unsafe fn register_typedef(
    type_name: *const c_char,
    alias_id: c_int
) -> c_int
[src]

Calls C++ function: static int QMetaType::registerTypedef(const char* typeName, int aliasId).

pub unsafe fn save(
    stream: impl CastInto<Ref<QDataStream>>,
    type_: c_int,
    data: *const c_void
) -> bool
[src]

Writes the object pointed to by data with the ID type to the given stream. Returns true if the object is saved successfully; otherwise returns false.

Calls C++ function: static bool QMetaType::save(QDataStream& stream, int type, const void* data).

C++ documentation:

Writes the object pointed to by data with the ID type to the given stream. Returns true if the object is saved successfully; otherwise returns false.

The type must have been registered with qRegisterMetaType() and qRegisterMetaTypeStreamOperators() beforehand.

Normally, you should not need to call this function directly. Instead, use QVariant's operator<<(), which relies on save() to stream custom types.

See also load() and qRegisterMetaTypeStreamOperators().

pub unsafe fn size_of_1a(type_: c_int) -> c_int[src]

Returns the size of the given type in bytes (i.e. sizeof(T), where T is the actual type identified by the type argument).

Calls C++ function: static int QMetaType::sizeOf(int type).

C++ documentation:

Returns the size of the given type in bytes (i.e. sizeof(T), where T is the actual type identified by the type argument).

This function is typically used together with construct() to perform low-level management of the memory used by a type.

This function was introduced in Qt 5.0.

See also construct().

pub unsafe fn size_of_0a(&self) -> c_int[src]

Returns the size of the type in bytes (i.e. sizeof(T), where T is the actual type for which this QMetaType instance was constructed for).

Calls C++ function: int QMetaType::sizeOf() const.

C++ documentation:

Returns the size of the type in bytes (i.e. sizeof(T), where T is the actual type for which this QMetaType instance was constructed for).

This function is typically used together with construct() to perform low-level management of the memory used by a type.

This function was introduced in Qt 5.0.

See also QMetaType::construct() and QMetaType::sizeOf().

pub unsafe fn type_char(type_name: *const c_char) -> c_int[src]

Returns a handle to the type called typeName, or QMetaType::UnknownType if there is no such type.

Calls C++ function: static int QMetaType::type(const char* typeName).

C++ documentation:

Returns a handle to the type called typeName, or QMetaType::UnknownType if there is no such type.

See also isRegistered(), typeName(), and Type.

pub unsafe fn type_q_byte_array(
    type_name: impl CastInto<Ref<QByteArray>>
) -> c_int
[src]

This is an overloaded function.

Calls C++ function: static int QMetaType::type(const QByteArray& typeName).

C++ documentation:

This is an overloaded function.

Returns a handle to the type called typeName, or 0 if there is no such type.

This function was introduced in Qt 5.5.

See also isRegistered() and typeName().

pub unsafe fn type_flags(type_: c_int) -> QFlags<TypeFlag>[src]

Returns flags of the given type.

Calls C++ function: static QFlags<QMetaType::TypeFlag> QMetaType::typeFlags(int type).

C++ documentation:

Returns flags of the given type.

This function was introduced in Qt 5.0.

See also QMetaType::TypeFlags.

pub unsafe fn type_name(type_: c_int) -> *const c_char[src]

Returns the type name associated with the given typeId, or a null pointer if no matching type was found. The returned pointer must not be deleted.

Calls C++ function: static const char* QMetaType::typeName(int type).

C++ documentation:

Returns the type name associated with the given typeId, or a null pointer if no matching type was found. The returned pointer must not be deleted.

See also type(), isRegistered(), and Type.

pub unsafe fn unregister_type(type_: c_int) -> bool[src]

Calls C++ function: static bool QMetaType::unregisterType(int type).

Trait Implementations

impl CppDeletable for QMetaType[src]

unsafe fn delete(&self)[src]

Destructs this object.

Calls C++ function: [destructor] void QMetaType::~QMetaType().

C++ documentation:

Destructs this object.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.