Skip to content

How convert the correct type between ModelRc and array(vec) #5244

Answered by tronical
keith331 asked this question in General
Discussion options

You must be logged in to vote

After the downcast_ref() call you have a VecModel reference. Here's a self-contained example:

use slint::Model;

slint::slint! {
    import { CheckBox, VerticalBox } from "std-widgets.slint";
    export component App {
        in-out property<[bool]> checked_array: [true, true, true, false];
        callback sig-checked([bool]);
        VerticalBox {
            for item[idx] in checked_array: CheckBox {
                text: @tr("Item {}",idx);
                checked: root.checked_array[idx];
                toggled => {
                    root.checked_array[idx] = !root.checked_array[idx];
                    root.sig-checked(root.checked_array);
                }
            }
        }

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@keith331
Comment options

@tronical
Comment options

Answer selected by keith331
@keith331
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants