Skip to content

How do you instantiate a non-window component from Rust code? #7443

Answered by jacklund
jacklund asked this question in Q&A
Discussion options

You must be logged in to vote

Never mind. I think I'm still getting used to the Slint way of doing things.

For those who come across this, you basically create a global property with an array of structs containing the values that the component needs, which starts out empty, and a for loop over the property array which instantiates the components using the provided struct data. On the Rust side, you connect the property with, say, a VecModel, like here, and then you can push new items onto the model, as done here. The for loop you set up in the Slint code will then automagically update the UI with the new component(s).

Please, anyone who knows more about this feel free to correct/expand on my explanation.

Replies: 1 comment

Comment options

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