QProgressBar not showing
-
I have an Extra Form with a QProgressBar that i want to use at different Points. First im using it at the start of the Application, where i download a JSon File. That works fine.
Now i want to download Git Repositories, that are listed in a QTableView. The download works, but the Form with the QProgressBar makes Problems. The Form shows up and closes, but the Form didnt show up the Progress.
This is my Code
void MainWindow::on_pbInstallFilter_clicked() { QModelIndexList indexList = ui->tvAvailableFilters->selectionModel()->selectedIndexes(); ProgressForm progress; progress.setWindowModality(Qt::WindowModality::WindowModal); int count = 0; progress.setMinimum(count); progress.setMaximum(indexList.count()); progress.show(); for (const QModelIndex &index : indexList) { progress.setValue(count); QString name, repo; name = index.model()->index(index.row(), 0, QModelIndex()).data().toString(); repo = index.model()->index(index.row(), 1, QModelIndex()).data().toString(); if (!mRepo.fetchRepository(name, repo)) QMessageBox::warning(this, "Git Repo Download Error", mRepo.getError(), QMessageBox::Ok); count++; } progress.setValue(count); progress.close(); }
When i use ProgressForm progress(this) instead of just ProgressForm progress, then he shows the QProgressBar, but the Window is very buggy and dont shows centered and is a little bit transparent.
-
I have an Extra Form with a QProgressBar that i want to use at different Points. First im using it at the start of the Application, where i download a JSon File. That works fine.
Now i want to download Git Repositories, that are listed in a QTableView. The download works, but the Form with the QProgressBar makes Problems. The Form shows up and closes, but the Form didnt show up the Progress.
This is my Code
void MainWindow::on_pbInstallFilter_clicked() { QModelIndexList indexList = ui->tvAvailableFilters->selectionModel()->selectedIndexes(); ProgressForm progress; progress.setWindowModality(Qt::WindowModality::WindowModal); int count = 0; progress.setMinimum(count); progress.setMaximum(indexList.count()); progress.show(); for (const QModelIndex &index : indexList) { progress.setValue(count); QString name, repo; name = index.model()->index(index.row(), 0, QModelIndex()).data().toString(); repo = index.model()->index(index.row(), 1, QModelIndex()).data().toString(); if (!mRepo.fetchRepository(name, repo)) QMessageBox::warning(this, "Git Repo Download Error", mRepo.getError(), QMessageBox::Ok); count++; } progress.setValue(count); progress.close(); }
When i use ProgressForm progress(this) instead of just ProgressForm progress, then he shows the QProgressBar, but the Window is very buggy and dont shows centered and is a little bit transparent.
When ProgressForm is based on QProcessDialog the subsequent might describe the issue of not showing for a while
A common problem with progress dialogs is that it is difficult to know when to use them; operations take different amounts of time on different hardware. QProgressDialog offers a solution to this problem: it estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond minimumDuration() (4 seconds by default).
-
Hi,
Depending on how
fetchRepository
is implemented you'll be blocking the event loop thus your dialog won't show up until everything is done so closed also immediately.