Macro qml::Q_LISTMODEL [] [src]

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

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

Unlike Q_LISTMODEL_ITEM macro, uses tuple as a data source.

Examples

Q_LISTMODEL!{
    pub QTestModel {
        name: String,
        number: i32
    }
}

// ...

let mut qqae = QmlEngine::new();
let mut qalm = QTestModel::new();
qalm.append_row("John".into(), 42);
qalm.append_row("Oak".into(), 505);
// `&QTestModel` implements `Into<QVariant>`
qqae.set_and_store_property("listModel", &qalm);

qqae.load_file("examples/listmodel.qml");
qalm.set_data(vec![("OMG".into(), 13317), ("HACKED".into(), 228)]);
qalm.change_line(0, "Everything's alright".into(), 123);
qqae.exec();