Macro qmetaobject::qt_property[][src]

macro_rules! qt_property {
    ($t:ty $(; $($rest:tt)*)*) => { ... };
}

This macro can be used as a type of a field and can then turn this field in a Qt property. The first parameter is the type of this property. Then we can have the meta keywords similar to these found in Q_PROPERTY.

Can be used within a struct that derives from QObject or QGadget

NOTIFY followed by the name of a signal that need to be declared separately. WRITE followed by the name of a setter. READ follow by the name of a getter. Note that these are not mandatory and if no setter or no getter exist, it will set the field. CONST is also supported.

ALIAS followed by an identifier allow to give a different name than the actual field name.

#[derive(QObject)]
struct Foo {
   base: qt_base_class!(trait QObject),
   foo: qt_property!(u32; NOTIFY foo_changed WRITE set_foo),
   foo_changed: qt_signal!(),
}

impl Foo {
   fn set_foo(&mut self, val: u32) { self.foo = val; }
}