Unsolved How to restrict a QSpinBox with following restrictions
-
- It should not take 01,002.. It should take 0 or 1 or 2 i.e 0 should not be prefixed with natural numbers.
- It should not take 00000000000000000000000000000000
-
Hi
You can use
http://doc.qt.io/qt-5/qspinbox.html#validate
to check if input is "legal" -
Can you send a snippet please.The document is hard to understand
-
Hi, its protected so you will need to subclass for it.
Maybe others have better idea/easier.Did you try with valueChanged() signal ?
It accepts ints and 001 is also valid int, so it might be a bit hard to get rid of.
-
Hi @mrjj
In designer mode I have a QSpinBox when I call mainwindow.show() and enter value in QSpinBox it should not take- 000000000000000
and - 01,002,.. It should take 0,1,2
Can you suggest?
- 000000000000000
-
@Sriu1 a 0 is only valid as a intermetiate state, as soon as you press return or the QSpinbox looses focus, the display inside the QSpinbox should correct itself to a number bewteen 1-9 before the comma or a 0 if its the only digit
-
@J-Hilk Is there any way to restrict the user from not entering 00000000000000000000000.
-
Hi,
What is the problem with you users entering such a big number of zeros ?