Skip to content

How do I continue updating a window after running it with .run() ;) #8121

Answered by guimath
111nation asked this question in Q&A
Discussion options

You must be logged in to vote

For synchronous, you could have a timer in your slint app that triggers a callback that you can then use to do whatever in rust.

In your MainWindow in slint :

callback refresh();

timer := Timer {
    interval: 1s;
    running: true;
    triggered() => {
        refresh();
    }
}

and then in rust before your window.run() :

window.on_refresh({
    let window_handle = window.as_weak();
    move || {
        let window = window_handle.unwrap();
        timer.dec_second();
        window.set_time(timer.to_str().to_shared_string());
    }
});

This is probably not the fastest way to do it, and if thats not enough you should indeed look into asynchronous with a timer directly in rust but thats …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by 111nation
Comment options

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