⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

ProgressBar doesn't redraw until function returns control

  • Greetings!
    I'm redesigning an application which handles telemetry data and performs visualization to use QML for it's GUI.
    Data processing takes noticeable amount of time on large input files, so I've decided adding a progress bar for indication.
    Processing method emits a signal when called, a signal per each fifth iteration and a signal before return, but the GUI never redraws before the method return control.
    Is there a viable solution to force redraw from QML signal handler?
    @import QtQuick 1.1
    import com.hertz 1.0
    import "ProgressBar" // from QtExamples

    Item {
    width: 300; height: 250

    Opener {
    id: opener
    onStart: { console.log('Started'); pb.value = 0 }
    onProcess: { pb.value = val; Qt.processEvents() }
    onEnd: console.log('Finished')

    ProgressBar {
    id: pb
    width: 300

    MouseArea {
    anchors.fill: parent
    onClicked: opener.open()
    P.S. I cannot alter Opener class (the only allowed modification is addition of three signals and their emission during data processing. Since there is no such standard component as ProgressBar, I see a solution in implementing ProgressBar in C++ and then exporting it to QML, but I hope there is a more elegant solution.

  • Where is "val" coming from and what is its value?

  • 'val' most likely comes from the process signal.

    I've been having the same issue, signals emitted from c++ don't update my progress bar until the c++ code returns.

  • Make sure the intensive C++ code runs in a separate thread then?

Log in to reply