Selaa lähdekoodia

BUG: Setting pre/suffix to ctkSliderSpinBoxWidget doesn't resize spinboxes

When AutoSpinboxWidth is on, we need to recompute the new sizehint for all
the spinboxes of the same grandparent.
A call to updateSpinboxWidth would be enough but a bug in Qt (QT-BUG-9530)
doesn't recompute the size hint of the spinbox. Calling setRange fix it.
Julien Finet 15 vuotta sitten
vanhempi
commit
ec062206b4
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      Libs/Widgets/ctkSliderSpinBoxWidget.cpp

+ 12 - 0
Libs/Widgets/ctkSliderSpinBoxWidget.cpp

@@ -343,6 +343,12 @@ void ctkSliderSpinBoxWidget::setPrefix(const QString& newPrefix)
 {
   CTK_D(ctkSliderSpinBoxWidget);
   d->SpinBox->setPrefix(newPrefix);
+#if QT_VERSION < 0x040800
+  /// Setting the prefix doesn't recompute the sizehint, do it manually here:
+  /// See: http://bugreports.qt.nokia.com/browse/QTBUG-9530
+  d->SpinBox->setRange(d->SpinBox->minimum(), d->SpinBox->maximum());
+#endif
+  d->updateSpinBoxWidth();
 }
 
 // --------------------------------------------------------------------------
@@ -357,6 +363,12 @@ void ctkSliderSpinBoxWidget::setSuffix(const QString& newSuffix)
 {
   CTK_D(ctkSliderSpinBoxWidget);
   d->SpinBox->setSuffix(newSuffix);
+#if QT_VERSION < 0x040800
+  /// Setting the suffix doesn't recompute the sizehint, do it manually here:
+  /// See: http://bugreports.qt.nokia.com/browse/QTBUG-9530
+  d->SpinBox->setRange(d->SpinBox->minimum(), d->SpinBox->maximum());
+#endif
+  d->updateSpinBoxWidth();
 }
 
 // --------------------------------------------------------------------------