ProgressBar doesn't redraw until function returns control
-
wrote on 12 May 2012, 09:22 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 QtExamplesItem {
width: 300; height: 250Opener {
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. -
wrote on 16 May 2012, 05:14 last edited by
Where is "val" coming from and what is its value?
-
wrote on 31 May 2013, 14:53 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.
-
wrote on 31 May 2013, 19:22 last edited by
Make sure the intensive C++ code runs in a separate thread then?