I want my Qt Spin-box to rotate the values when an user reaches the two ends of the value range.
e.g. let my range is 0 to 10 with increments of 2. After clicking the increment button of the spin-box when the value is already 10, usually nothing happens. But I want it to rotate the value back to the first value which will be 0.
Which member function shall I have to override to catch the event of the user- attempt to change the value in QSpinBox class?
class MyCustomSpinBox : public QSpinBox
{
// override this function to get the effect of rotating
void override_func()
{
// code to rotate the value
}
};
Or, is it that there already exists some property of it such that I can just set in qt-creator (may-be) to get the same rotating values effect?
Thanks.
you can just enable wrapping .
For example.
QSpinBox *spinBox = new QSpinBox(this);
spinBox->setRange(0, 100);
spinBox->setWrapping(true);
spinBox->setValue(100);
spinBox->stepBy(1);
// value is 0