mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
C++: implement Window::on_close_requested
This commit is contained in:
parent
737109e60e
commit
ca5151de11
6 changed files with 82 additions and 17 deletions
|
@ -30,5 +30,19 @@ int main()
|
|||
}
|
||||
});
|
||||
|
||||
demo->on_popup_confirmed(
|
||||
[demo = slint::ComponentWeakHandle(demo)] { (*demo.lock())->window().hide(); });
|
||||
|
||||
demo->window().on_close_requested([todo_model, demo = slint::ComponentWeakHandle(demo)] {
|
||||
int count = todo_model->row_count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!todo_model->row_data(i)->checked) {
|
||||
(*demo.lock())->invoke_show_confirm_popup();
|
||||
return slint::CloseRequestResponse::KeepWindowShown;
|
||||
}
|
||||
}
|
||||
return slint::CloseRequestResponse::HideWindow;
|
||||
});
|
||||
|
||||
demo->run();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue