How can I control a ProgressIndicator value from Rust #8466
Unanswered
bob-anderson-ok
asked this question in
Q&A
Replies: 4 comments 3 replies
-
You can define a Then you can two-way bind this value to the progress indicator's |
Beta Was this translation helpful? Give feedback.
0 replies
-
What does the Rust side look like?
Bob
…On Mon, May 19, 2025 at 1:31 AM Tobias Hunger ***@***.***> wrote:
You can define a image-load-progress in property in your root Element (or
a global) and set this value from rust.
Then you can two-way bind this value to the progress indicator's value.
—
Reply to this email directly, view it on GitHub
<#8466 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG6OD3WZE7A3AULKTC4NI327GJGZAVCNFSM6AAAAAB5MIT53WVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJZGA4DCOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
The function that needs to update the progress indicator is defined outside
of main (of course). But ui is defined inside of main. What is a good way
to make ui visible to that external function? I am not averse to using
static and unsafe as my app is single threaded.
Bob
…On Mon, May 19, 2025 at 9:21 AM Tobias Hunger ***@***.***> wrote:
It depends on whether you define the property on the Window or a global
object:
export component MainWindow {
in-out property <int> image-load-progress-value: 0;
[...]
ProgressBar {
value <=> root.image-load-progress-value;
}
}
// create the UI:let ui = MainWindow::new()?;
[...]
ui.set_image_load_progress_value(0);
—
Reply to this email directly, view it on GitHub
<#8466 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG6OD2HICJJZBPFGANYRB327IAG5AVCNFSM6AAAAAB5MIT53WVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMJZGYYDMNY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
This simple idea seems to be impossible in a Slint/Rust program: show the
progress of a long running rust callback using a Slint progress bar.
The essential difficulty is that once a rust callback is called from Slint,
Slint will do nothing until the callback completes and returns to Slint
To get around this, the rust callback could be redesigned to execute its
task in small pieces timewise and return to Slint with a progress indicator
that Slint can use to adjust progress bar and reissue the callback if more
work is needed. But this idea is difficult to implement as I do not know
how to implement a co-routine pattern in rust where a function can be
re-entered and pick up where it last left off.
I gave up and use println! to console to show progress - a poor substitute.
Bob
…On Wed, Jun 25, 2025 at 2:25 AM Max ***@***.***> wrote:
I need to use the same logic, display a progress of a long task, may be
from different Thread etc...
I use the pattern in C# :
var progress = (IProgress)new Progress(updateProgress);
to report the progress to UI Thread from others but I don't know what is
the best practice to do it with Slint and Rust.
—
Reply to this email directly, view it on GitHub
<#8466 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABG6OD3LCTLQPYQQOKO3PMD3FJTH3AVCNFSM6AAAAAB5MIT53WVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGNJXGE3DANY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an image that I compute and display in an Slint Image widget through a pure callback called render_image(...) -> Image:
This works well as I can trigger a call to render_image with a simple refresh-image += 1 in response to widget clicks or edits.
My problem is that sometimes the image calculation can be lengthy and I want to use a ProgressIndicator to inform the user as to what's going on. But I do not know how to change a widget property (ProgressIndicator value) from the rust side outside of a callback. It seems a violation of the reactive principals that Slint is based on and that may be why I cannot find an example. I'm guessing that I somehow need to interact with the Slint event queue, but I cannot find any example that I can understand that follows this path.
I'm looking for some threads to pull on.
Beta Was this translation helpful? Give feedback.
All reactions