Skip to content

Explicitly changing the Slint's slint::Model<> to slint::VectorModel<> in C++ #6520

Answered by tronical
allankoechke asked this question in Q&A
Discussion options

You must be logged in to vote

I see two options:

  1. You share the model upfront. So in the above C++ code that would mean not calling auto tiles_model = main_window->get_memory_tiles(); in the callback, but instead adding a copy of the original tiles_model that has the type std::shared_ptr<slint::VectorModel<TileData>> into the callback's closure as captured variable (by value).
  2. If you know that the model is a vector model, I think that you could cast it: auto tiles_model = static_cast<std::shared_ptr<slint::VectorModel<TileData>>>(main_window->get_memory_tiles());.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by allankoechke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants