Skip to content
Discussion options

You must be logged in to vote

Right, you will want to map the Vec to a Vec.
You can do something like so:

let my_vec : Vec<String> = ...;
let my_vec : Vec<slint::SharedString> = my_vec.into_iter().map(Into::into).collect();
let model = slint::ModelRc::new(VecModel::from(vec!["Hello".into(), "World".into()]));

my_ui.set_some_property(model);

(I haven't tried this code)

If you want to automatically react to change in the vector, you may want to have a Rc<VecModel<SharedString>> instead and operate in that instead of on the Vec<String>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pieterdd
Comment options

Answer selected by pieterdd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants