Why slider and label do not display intermediate results sent by signal from Connections? Slider and label only display the final result. How to make it appear consistently?
test.py
class Test(QObject):
percent = pyqtSignal(int, arguments=['percent'])
@pyqtSlot()
def start(self):
for i in range(101):
self.percent.emit(i)
print(i)
time.sleep(0.1)
if __name__ == '__main__':
test = Test()
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.rootContext().setContextProperty("Test", test)
engine.load('test.qml')
sys.exit(app.exec_())
This is test.qml
ApplicationWindow {
visible: true
width: 500
height: 100
RowLayout {
Slider {
id: slider
implicitWidth: 300
from: 1
value: 1
to: 100
}
Label {
id: label
width: 100
text: "0"
}
Button {
highlighted: true
text: "Go"
onClicked: {
Test.start()
}
}
}
Connections {
target: Test
function onPercent(percent) {
slider.value = percent
label.text = percent
}
}
}
Slider and label only display the final result. How to make it appear consistently?