I have a QSpinbox
whose range I am setting:
QSpinBox *SpinBox = new QSpinBox;
SpinBox->setRange(0, 100);
However, I'm able to manually enter a +
sign which is not reflected in my slot.
connect (SpinBox, SIGNAL (valueChanged (QString)), this,
SLOT (onSpinBoxChanged (QString)));
I tried replacing QString
with int
also. But +
is not reflected in the slot.
How can I restrict entering the +
sign?
I have referred some Qt and StackOverflow posts/answers of disabling the line-edit in the spinbox:
I tried to make the spinbox's line-edit ReadOnly
but I am unable to do so since it's a const
variable.
Some answers suggest inheriting the QSpinbox
class.
Is there any other approach to restrict the +
sign or disabling the QSpinbox
's line-edit itself?