QAbstractSlider - adding setRange as a slot
In many situations it would be very nice to have setRange as a slot. It fits good with the rangeChanged signal - and in some situations it does make sense to synchronize scrollbars ranges. Change-Id: I6bcb41ed6e009e5822b56b621e4e187fe52502a6 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
parent
db1abf9f76
commit
87975f88ce
@ -79,8 +79,6 @@ public:
|
||||
void setMaximum(int);
|
||||
int maximum() const;
|
||||
|
||||
void setRange(int min, int max);
|
||||
|
||||
void setSingleStep(int);
|
||||
int singleStep() const;
|
||||
|
||||
@ -120,6 +118,7 @@ public:
|
||||
public Q_SLOTS:
|
||||
void setValue(int);
|
||||
void setOrientation(Qt::Orientation);
|
||||
void setRange(int min, int max);
|
||||
|
||||
Q_SIGNALS:
|
||||
void valueChanged(int value);
|
||||
|
@ -93,6 +93,7 @@ private slots:
|
||||
void setValue_data();
|
||||
void setValue();
|
||||
void setRepeatAction();
|
||||
void connectedSliders();
|
||||
|
||||
private:
|
||||
void waitUntilTimeElapsed(const QTime& t, int ms);
|
||||
@ -1259,5 +1260,17 @@ void tst_QAbstractSlider::setRepeatAction()
|
||||
QCOMPARE(slider->value(), 115);
|
||||
}
|
||||
|
||||
void tst_QAbstractSlider::connectedSliders()
|
||||
{
|
||||
Slider *slider2 = new Slider(topLevel);
|
||||
connect(slider, SIGNAL(rangeChanged(int, int)), slider2, SLOT(setRange(int, int)));
|
||||
const int sliderlow = 13;
|
||||
const int sliderhigh = 1017;
|
||||
slider->setRange(sliderlow, sliderhigh);
|
||||
QCOMPARE(slider2->minimum(), sliderlow);
|
||||
QCOMPARE(slider2->maximum(), sliderhigh);
|
||||
delete slider2;
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAbstractSlider)
|
||||
#include "tst_qabstractslider.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user