Explicitly changing the Slint's slint::Model<> to slint::VectorModel<> in C++ #6520
-
Looking at the memory game shipped as part of the Slint examples for C++, we have the model defined as follows;
On the C++ side, we create a shared
Is there a way to explicitly set the slint model to always be a VectorModel or convert the model to VectorModel? Or what's the preferred approach to avoiding creating a new VectorModel in every callback call, and copying the data over just to invoke the vector's |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I see two options:
|
Beta Was this translation helpful? Give feedback.
I see two options:
auto tiles_model = main_window->get_memory_tiles();
in the callback, but instead adding a copy of the originaltiles_model
that has the typestd::shared_ptr<slint::VectorModel<TileData>>
into the callback's closure as captured variable (by value).auto tiles_model = static_cast<std::shared_ptr<slint::VectorModel<TileData>>>(main_window->get_memory_tiles());
.