How to create progress bar showing the progress of task running in background
Unsolved
General and Desktop
-
Hi All,
In my project, there are some tasks that runs in background and as tasks gets completed, results are displayed in Gui.
I want to create a progress bar that will display the progress of tasks running in background.Please suggest..how this can be achieved..
Regards,
Anuj -
Hello,
You can put the progress bar in status bar if you are using a QMainWindow:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { //class initialization //... m_progress = new QProgressBar; statusBar()->addPermanentWidget(m_progress); m_progress->hide(); //... } void MainWindow::onProcessStarted() { m_progress->show(); } void MainWindow::onProcessFinished() { m_progress->hide(); } void MainWindow::onProgressValueChanged(int progressValue) { m_progress->setValue(progressValue); } void MainWindow::onProgressMaxChanged(int progressMax) { m_progress->setMaximum(progressMax); }
If you want to show several progress bars at the same time, a list view of progress bars could be a better approach