-
I have this struct that I'm going to encapsulate in a #[derive(Debug, Clone)]
pub struct ResolvedModEntry {
mod_ref: Mod,
entry: ModEntry,
} I'd like to then bind this model to a For one thing, it won't recognize the type if I try to set the property up like this: export component ModTableView {
in property <[ResolvedModEntry]> model;
StandardTableView {}
} Here's my code: https://github.com/poperigby/barnacle/ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sorry if I am a bit late to the party. To make Slint aware of those structs you'll have to write those data structs from within Slint. Assuming export struct Mod { /* put the fields here */ }
export struct ModEntry { /* put the fields here */ }
export struct ResolvedModEntry {
mod_ref: Mod,
entry: ModEntry,
} Those structs are then available as regular Rust structs. If you want to start with a StandardTableView you'll have to create a two-dimensional With a ListView you are more flexible and populate the model with the export AppWindow inherits Window {
in property <[ResolvedModEntry]> mod_model;
VerticalBox {
list := ListView {
for e in root.mod_model: Rectangle {
HorizontalLayout {
Text {
text: e.entry.name; // assuming a name field exists in mod
}
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
Sorry if I am a bit late to the party. To make Slint aware of those structs you'll have to write those data structs from within Slint. Assuming
Mod
andModEntry
are also structs:Those structs are then available as regular Rust structs.
If you want to start with a StandardTableView you'll have to create a two-dimensional
Vec
in Rust and copy the display data to StandardListviewItem'stext
property. Just wrote an example forStandardTableView
few days ago for this discussion.With a ListView you are more flexible …