Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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
You can use
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.
In designer mode I have a QSpinBox when I call mainwindow.show() and enter value in QSpinBox it should not take
- 01,002,.. It should take 0,1,2
Can you suggest?
@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.
What is the problem with you users entering such a big number of zeros ?