-
Code: {
let ui_week = ui.as_weak();
{
let ui_week = ui_week.unwrap();
ui.on_search(move || {
let name = ui_week.get_file_name();
let path = ui_week.get_path();
let mut fd = FdCommand::new();
fd.set_path(&path);
fd.file_name(&name);
let rows: Rc<VecModel<slint::ModelRc<StandardListViewItem>>> = Rc::new(VecModel::default());
let rows_clone = rows.clone();
fd.run(move |path| {
let items = Rc::new(VecModel::default());
items.push(StandardListViewItem::from(slint::format!("{}", path)).into());
rows_clone.push(items.clone().into());
}).unwrap();
ui_week.set_rows(rows.clone().into());
});
}
} slint:
How to set row data in StandardListView immediately after getting some of the result, like: fd.run(move |path| {
let items = Rc::new(VecModel::default());
let entry = StandardListViewItem::from(slint::format!("{}", path));
items.push(entry);
rows_clone.push(items.clone().into());
fark.set_row(rows_clone);
})
.unwrap(); |
Beta Was this translation helpful? Give feedback.
Answered by
tronical
Jan 11, 2024
Replies: 2 comments 4 replies
-
I try to use let (tx, rx): (
Sender<SendWrapper<Rc<VecModel<ModelRc<StandardListViewItem>>>>>,
_,
) = mpsc::channel();
let ui_week = ui.as_weak();
std::thread::spawn(move || {
loop {
if let Ok(rx) = rx.try_recv() {
let rx = rx.clone().take();
ui_week.upgrade_in_event_loop(move |w| {
w.set_rows(rx.clone().into());
});
}
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
I can see two options:
Would that work for you? |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
eatradish
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can see two options:
Vec
instead of theVecModel
/ModelRc
- that'sSend
.ModelRc
fromui_week
(w
in the closure) first and then callpush
, like in the example at the very bottom of https://docs.rs/slint/latest/slint/struct.ModelRc.html#exampleWould that work for you?