C++: sort the member of a struct in the same order as in the .slint file

This commit is contained in:
Olivier Goffart 2023-03-29 19:11:33 +02:00 committed by GitHub
parent 2e1ce47b79
commit cdaf2abb47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 22 deletions

View file

@ -8,15 +8,19 @@ int main()
auto demo = MainWindow::create();
auto todo_model = std::make_shared<slint::VectorModel<TodoItem>>(std::vector {
TodoItem { true, "Implement the .slint file" }, TodoItem { false, "Do the Rust part" },
TodoItem { true, "Make the C++ code" },
TodoItem { false, "Write some JavaScript code" },
TodoItem { false, "Test the application" }, TodoItem { false, "Ship to customer" },
TodoItem { false, "???" }, TodoItem { false, "Profit" } });
TodoItem { "Implement the .slint file", true },
TodoItem { "Do the Rust part", false },
TodoItem { "Make the C++ code", true },
TodoItem { "Write some JavaScript code", false },
TodoItem { "Test the application", false },
TodoItem { "Ship to customer", false },
TodoItem { "???", false },
TodoItem { "Profit", false },
});
demo->set_todo_model(todo_model);
demo->on_todo_added([todo_model](const slint::SharedString &s) {
todo_model->push_back(TodoItem { false, s });
todo_model->push_back(TodoItem { s, false });
});
demo->on_remove_done([todo_model] {