Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    ProgressBar doesn't redraw until function returns control

    QML and Qt Quick
    4
    4
    3006
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DieHertz last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • C
        ChrisW67 last edited by

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

        1 Reply Last reply Reply Quote 0
        • A
          acranbury last edited by

          '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.

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post