P
P
Perzh2014-07-30 10:03:36
Qt
Perzh, 2014-07-30 10:03:36

How to make QProgressBar full?

Hello.
I am using QProgressDialog. Inside it has a QProgressBar, which at some point needs to be set to the maximum (fill), to show that the process is completed.

PB = new QProgressDialog(this);
PB->setAutoClose(false);
PB->setWindowModality(Qt::WindowModal);
PB->setMinimum(1);
PB->setMaximum(100);
PB->setValue(100); // прогресс бар становится пустым

The bottom line is that when you set the current value to the maximum, the progress bar becomes empty instead of filling. I don't know how to fix it. Please tell me how to set the value to the maximum?
ZY: tried different methods:
// #1
PB->setValue(PB->maximum()); // тоже самое
// #2
PB->setValue(PB->maximum() - 1); // округляется до 99%
// #3
PB->setMaximum(100);
PB->setValue(99.99999f); // округляется до 99%

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Perzh, 2014-07-30
@Perzh

For future applicants: QProgressDialog has an autoReset property ( true by default ) that is responsible for resetting value when it reaches the maximum. To solve the problem, you need to set this property to false :

p_diag = new QProgressDialog(this);
p_diag->setAutoClose(false);
p_diag->setAutoReset(false); // do not reset value

D
DancingOnWater, 2014-07-30
@DancingOnWater

ui->progressBar->setValue(ui->progressBar->maximum());

This code definitely works. The problem is in the surrounding code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question