Unsolved QMediaPlayer::positionChanged causes delay on my progressBar
-
Hello.
I have connected the signal from QMediaPlayer::positionChanged to my MainWindow::trackPositionChanged
// in the constructor QObject::connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(trackDurationChanged(qint64))); QObject::connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(trackPositionChanged(qint64))); // void MainWindow::trackDurationChanged(qint64 position) { ui->progressBar->setMaximum(position); } void MainWindow::trackPositionChanged(qint64 position) { ui->progressBar->setValue(position); }
The problem with this is that the progressBar doesn't update in real-time.
This is a screenshot of when I press play
And this is a screenshot after 3 seconds have passed
As you can see, the progressBar did a "jump" from being completely empty to one "green block".
What I want, instead, is watching the progressBar filling up little by little, smoothly.
(I know this happens in relation to the progressBar's lenght)
How can I achieve this?
Thanks in advance! -
The default interval for change notifications is 1000ms (1 second). If you want a smooth update set it to something lower with setNotifyInterval().
-
@Chris-Kawa said in QMediaPlayer::positionChanged causes delay on my progressBar:
The default interval for change notifications is 1000ms (1 second). If you want a smooth update set it to something lower with setNotifyInterval().
Thanks for the answer.
Changing the notifyInterval (to 10 for example) is effective on my slider... but on the progressBar, the issue persists. There's a new green block popping up every X seconds.
The slider is smoother