-
Hi, I created a small application to test rust with slint Multimeter Control and I have some architecture design questions. let app = app_weak.unwrap();
let model = app.get_dmm_data();
let model = model.as_any().downcast_ref::<VecModel<DmmData>>().unwrap();
model.push(DmmData { id, ip, connected: true, result: 0.0, terminal: Terminal::Front, mode: Mode::VoltageDc}); (https://gitlab.com/Murmele/multimetercontrol/-/blob/main/src/lib.rs?ref_type=heads#L30-L32)
struct DmmData {
ip: string,
} When the model changes, in slint new objects get created. That means that all previous Dmm objects get deleted and all are recreated? https://gitlab.com/Murmele/multimetercontrol/-/blob/main/ui/dmm-control.slint?ref_type=heads#L32-L43 for dmm in dmm_data: Dmm {
...
} export component Dmm inherits Rectangle {
in property <string> ip <=> ip-text.text;
HorizontalLayout {
ip-text:= Text {
text: "<IP>";
}
}
} Then I assign data to that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Whether the old values get deleted or not depends on what you do: They do get replaced when you replace the entire model (even if most entries contain the same data). They are not replaced when you add a new element into the current model. You seem to be doing the latter, but that is hard to tell with just a few snippets of code. The |
Beta Was this translation helpful? Give feedback.
It should only create components for the new entries in the model and keep the old ones around.