Updating QML display from long running process

I’m new to Julia QML and this list so I hope this all makes sense and that this is an appropriate place to post my question.

I have a long running Julia process which periodically pushes a notification to a JuliaItemModel as a model for a QML ListView. The GUI display works as expected except that it waits until the long running process completes before it updates the list and all the notifications appear at once. Is it possible for the display to be updated on receipt of each individual notification? What would be the idiomatic way to accomplish this? Many thanks for any guidance.

1 Like

It sounds like the Julia process does not give control to QML. I don’t know a proper solution here, but perhaps the issue can be resolved with emitting a dummy signal from Julia just after you update the ListModel in a long computation. That would hand over control to QML to process the signal and should redraw the UI before handing control back to Julia.

I don’t know, but you can look into if other GUi toolkit, like Mousetrap.jl (based on GTK4) is easier to work with and this possible there.

Hi Janis,
Many thanks for your reply.
Immediately after updating the model the process sends a signal to the QML which updates a text field with the same notification pushed to the list model. However, the same problem occurs which is that only when the process finishes does the text field update and it displays the last notification sent. I agree that this looks like a problem of the Julia process not yielding to the QML main thread, to allow that to run. I guess I will dig into Julia’s threading documentation and see if I can work out how to make this happen. This is not an area I have dug into yet so if anyone can point me in the right direction this will be much appreciated.

Immediately after updating the model the process sends a signal to the QML which updates a text field with the same notification pushed to the list model.

You are assuming that Julia yields to QML and back when updating the ListModel, whereas you have observed that the control to QML is given back only when the process is finished.

The behaviour should be different with @emit from a Julia side that hands control over to QML to process the signal. It should also work for the long-running processes.

Your issue is an excellent candidate for a Minimal Working Example (MWE). Creating one would help us identify any underlying issues that may prevent the update and make it easier for everyone to offer better suggestions and test them.