Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
があり、QSpinBox正の自然数のみを受け入れるようにします。ドットを入力するまで、これは正常に機能します.
QSpinBox
.
入力234235.23456してフォーカスを他のスピンボックスに変更すると、値が に変更され23423523456ます。
234235.23456
23423523456
だから私は背後にあるすべてを無視する方法を探しています.
これはサブクラス化せずに可能QSpinBoxですか?
問題の修正を見つけました:
QDoubleSpinBox * box = new QDoubleSpinBox(); box->setDecimals(0); box->setSingleStep(1.0); box->findChild<QLineEdit*>()->setValidator(new QRegExpValidator(QRegExp(QString("^[1-9][0-9]*$"))));