Answer the question
In order to leave comments, you need to log in
Why does QSpinbox allow null input?
Hello! There is a QSpinbox, it has boundary values from 1 to 83. The default value is 1. However, the spinbox skips (allows you to enter) such values:
0000000
01
083
0
Answer the question
In order to leave comments, you need to log in
You need to inherit the QSpinBox class and implement the validate method
class SpinBox : public QSpinBox
{
public:
SpinBox(QWidget *parent = 0) : QSpinBox(parent) {}
QValidator::State validate(QString &input, int &pos) const
{
if (input != "0") {
return QValidator::Acceptable;
} else {
return QValidator::Invalid;
}
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question