Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT progress bar speed

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?

like image 844
Lockhead Avatar asked Jun 14 '11 09:06

Lockhead


2 Answers

You can use QTimeLine for this. The detailed description in the documentation gives an example of exactly what you want.

like image 67
mtvec Avatar answered Oct 21 '22 13:10

mtvec


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.

like image 42
B. Decoster Avatar answered Oct 21 '22 11:10

B. Decoster