Explicitly changing the Slint's slint::Model<> to slint::VectorModel<> in C++ #6520
Unanswered
allankoechke
asked this question in
Q&A
Replies: 2 comments 2 replies
-
I see two options:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Option (1) works fine, option (2) doesnt seem to work. This throws an error on MSVC that we cant static_cast to |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
slint::VectorModel<>
and populate the model. However, in cases where the callback in this case,ui->on_check-if-pair-solved(...);
which is handled in C++, needs to add new items to the model, I assume the native way would be to just invokemodel->push_back(...)
which fails because the model in this context is the defaultslint::Model<>()
instead ofslint::VectorModel<>()
which was set earlier in the setup.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
push_back
function to add new items?Beta Was this translation helpful? Give feedback.
All reactions