C++: implement Window::on_close_requested

This commit is contained in:
Olivier Goffart 2022-03-17 11:15:48 +01:00 committed by Olivier Goffart
parent 737109e60e
commit ca5151de11
6 changed files with 82 additions and 17 deletions

View file

@ -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();
}