QProgressBar
-
@jagl It is clear when the timer will start.
What I'm talking about is the timer interval.
If you read the link I posted you will see: "A QTimer with a timeout interval of 0 will time out as soon as all the events in the window system's event queue have been processed.". So, you will get the timeouts very fast and your progress bar will also reach very fast 100%.
But, I don't understand why you invented a timer here? It will only work if you know in advance how long your back ground task will run. But you don't, right? -
@jsulm Please now the ProgressBar works but it does not reset
connect (&Watcher1, SIGNAL(progressRangeChanged(int,int)),ui->progressBar, SLOT(setRange(int,int)));
connect (&Watcher1, SIGNAL(progressValueChanged(int,int)),ui->progressBar, SLOT(setValue(int)));
connect (&Watcher, SIGNAL(finished()),ui->progressBar , SLOT(reset())); -
connect (&Watcher1, SIGNAL(progressRangeChanged(int,int)),ui->progressBar, SLOT(setRange(int,int)));
connect (&Watcher1, SIGNAL(progressValueChanged(int,int)),ui->progressBar, SLOT(setValue(int)));
connect (&Watcher, SIGNAL(finished()), this, SLOT(slotProcessBar()));
void Rover::slotProcessBar()
{ui-> progressBar->setMaximum(1); ui->progressBar->reset();
}
-
@jagl said in QProgressBar:
connect (&Watcher1, SIGNAL(progressRangeChanged(int,int)),ui->progressBar, SLOT(setRange(int,int)));
connect (&Watcher1, SIGNAL(progressValueChanged(int,int)),ui->progressBar, SLOT(setValue(int)));
connect (&Watcher, SIGNAL(finished()), this, SLOT(slotProcessBar()));I am pretty sure that those connect do not work.
As far as I can see, Watcher1 is defined asQFutureWatcher<void> Watcher1;
and Watcher asQFutureWatcher<void>Watcher;
So there is no signal
progressRangeChanged(int,int)
available... so how should this work? -
@jagl
Aren't you asking just the same question/problem in https://forum.qt.io/topic/128560/set-qlabel-from-another-thread/ ?As we asked you there, if you would please take the time to change over to the New Signal Slot Syntax you would save us & yourself a lot of time on what looks like incorrect
connect()
s. -
@jagl said in QProgressBar:
thank you for your reply but why she work ?
This do NOT work!
I know that C++ is not a language which is easy to learn, but it is mandatory to learn it before trying to create application with Qt.
It is also strongly recommended to read documentation.
It is Okay not to understand all the stuff. In this case you can ask what you do not understand.Do you have read
QFutureWatcher
documentation?
https://doc.qt.io/qt-5/qfuturewatcher.html#detailsQFutureWatcher
is a template class to simplifyQFuture
monitoring.
So you can be informed when the QFuture is finished.