summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/qprogressbar.cpp14
-rw-r--r--tests/auto/qprogressbar/tst_qprogressbar.cpp39
2 files changed, 49 insertions, 4 deletions
diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp
index 1b0a1a1..c583a78 100644
--- a/src/gui/widgets/qprogressbar.cpp
+++ b/src/gui/widgets/qprogressbar.cpp
@@ -341,11 +341,17 @@ int QProgressBar::value() const
void QProgressBar::setRange(int minimum, int maximum)
{
Q_D(QProgressBar);
- d->minimum = minimum;
- d->maximum = qMax(minimum, maximum);
- if ( d->value <(d->minimum-1) || d->value > d->maximum)
- reset();
+ if (minimum != d->minimum || maximum != d->maximum) {
+ d->minimum = minimum;
+ d->maximum = qMax(minimum, maximum);
+
+ if (d->value < (d->minimum - 1) || d->value > d->maximum)
+ reset();
+ else
+ update();
+ }
}
+
/*!
\property QProgressBar::textVisible
\brief whether the current completed percentage should be displayed
diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp
index 04b7ce7..878cce8 100644
--- a/tests/auto/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp
@@ -63,6 +63,7 @@ private slots:
void text();
void format();
void setValueRepaint();
+ void setMinMaxRepaint();
void sizeHint();
void formatedText_data();
void formatedText();
@@ -216,6 +217,44 @@ void tst_QProgressBar::setValueRepaint()
}
}
+void tst_QProgressBar::setMinMaxRepaint()
+{
+ ProgressBar pbar;
+ pbar.setMinimum(0);
+ pbar.setMaximum(10);
+ pbar.setFormat("%v");
+ pbar.show();
+ QTest::qWaitForWindowShown(&pbar);
+
+ QApplication::processEvents();
+
+ // No repaint when setting minimum to the current minimum
+ pbar.repainted = false;
+ pbar.setMinimum(0);
+ QTest::qWait(50);
+ QTRY_VERIFY(!pbar.repainted);
+
+ // No repaint when setting maximum to the current maximum
+ pbar.repainted = false;
+ pbar.setMaximum(10);
+ QTest::qWait(50);
+ QTRY_VERIFY(!pbar.repainted);
+
+ // Repaint when setting minimum
+ for (int i = 9; i >= 0; i--) {
+ pbar.repainted = false;
+ pbar.setMinimum(i);
+ QTRY_VERIFY(pbar.repainted);
+ }
+
+ // Repaint when setting maximum
+ for (int i = 0; i < 10; ++i) {
+ pbar.repainted = false;
+ pbar.setMaximum(i);
+ QTRY_VERIFY(pbar.repainted);
+ }
+}
+
void tst_QProgressBar::sizeHint()
{
ProgressBar bar;