Does QT provide any functions to control a progress bar's speed? For example, if I want it to increase by 1% every 1 second, is there any QT way to do it instead of using a loop and sleeping for 1 second between each value change?
You can use QTimeLine
for this. The detailed description in the documentation gives an example of exactly what you want.
Use a QTimer.
Connect the signal timeout()
to a slot that increases the value in the QProgressBar.
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);
In this cas, update()
will be call each second.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With