You can connect to actionTriggered(int) signal and prevent moving the slider to new value when current value is minimum() or maximum(), and new value seems to be "wrapped". Watch for QAbstractSlider::SliderMove action:
class NoWrapDial
: public QDial{ Q_OBJECT
public:
{
connect(this, SIGNAL(actionTriggered(int)), this, SLOT(onAction(int)));
}
protected slots:
void onAction(int val){
static const int minDistance = 1;
if (value() == maximum() && sliderPosition()<maximum()-minDistance) {
this->setSliderPosition(maximum());
} else if (value() == minimum() && sliderPosition()>minimum()+minDistance){
this->setSliderPosition(minimum());
}
}
}
};
class NoWrapDial : public QDial{
Q_OBJECT
public:
NoWrapDial(QWidget * parent = NULL) : QDial(parent)
{
connect(this, SIGNAL(actionTriggered(int)), this, SLOT(onAction(int)));
}
protected slots:
void onAction(int val){
static const int minDistance = 1;
if (val == QAbstractSlider::SliderMove) {
if (value() == maximum() && sliderPosition()<maximum()-minDistance) {
this->setSliderPosition(maximum());
} else if (value() == minimum() && sliderPosition()>minimum()+minDistance){
this->setSliderPosition(minimum());
}
}
}
};
To copy to clipboard, switch view to plain text mode
btw. this requires tracking to be enabled (the default)
Bookmarks