Macro qml::Q_LISTMODEL_ITEM [] [src]

macro_rules! Q_LISTMODEL_ITEM {
    (pub $wrapper:ident <$wrapper_item:ident> {
        $($rolename:ident : $roletype:ty,)*
    }) => { ... };
}

Generates a wrapper for QListModel for static typing and easier management.

Unlike Q_LISTMODEL macro, uses struct as a data source.

Examples

Q_LISTMODEL_ITEM!{
    pub QTestModel<TestModelItem> {
        name: String,
        number: i32,
    }
}

// ...

let mut qqae = QmlEngine::new();
let mut qalm = QTestModel::new();
let item1 = TestModelItem {
    name: "foo".into(),
    number: 42
};
let item2 = TestModelItem {
    name: "bar".into(),
    number: 23
};
qalm.append_item(item1);
qalm.append_item(item2);
// `&QTestModel` implements `Into<QVariant>`
qqae.set_and_store_property("listModel", &qalm);
qqae.exec();