pub trait QMetaType: Clone + Default + 'static {
    const CONVERSION_TO_STRING: Option<fn(_: &Self) -> QString> = None;
    const CONVERSION_FROM_STRING: Option<fn(_: &QString) -> Self> = None;

    // Provided methods
    fn register(name: Option<&CStr>) -> i32 { ... }
    fn id() -> i32 { ... }
    fn to_qvariant(&self) -> QVariant { ... }
    fn from_qvariant(variant: QVariant) -> Option<Self> { ... }
}
Expand description

Implement this trait for type that should be known to the QMetaObject system

Once implemented for a type, it can be used as a type of a qt_property! or as a parameter of a qt_method!

use qmetaobject::QMetaType;

#[derive(Default, Clone)]
struct MyStruct(u32, String);

impl QMetaType for MyStruct {}

Provided Associated Constants§

source

const CONVERSION_TO_STRING: Option<fn(_: &Self) -> QString> = None

If this is set to a function, it enable the conversion to and from QString

source

const CONVERSION_FROM_STRING: Option<fn(_: &QString) -> Self> = None

Provided Methods§

source

fn register(name: Option<&CStr>) -> i32

Registers the type.

See the Qt documentation of qRegisterMetaType()

The default implementation should work for most types

source

fn id() -> i32

source

fn to_qvariant(&self) -> QVariant

Returns a QVariant containing a copy of this object

source

fn from_qvariant(variant: QVariant) -> Option<Self>

Attempt to convert from a QVariant to this type.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl QMetaType for bool

source§

impl QMetaType for f32

source§

impl QMetaType for f64

source§

impl QMetaType for i8

source§

impl QMetaType for i16

source§

impl QMetaType for i32

source§

impl QMetaType for i64

source§

impl QMetaType for isize

source§

impl QMetaType for u8

source§

impl QMetaType for u16

source§

impl QMetaType for u32

source§

impl QMetaType for u64

source§

impl QMetaType for ()

source§

impl QMetaType for usize

source§

impl QMetaType for String

Implementors§