I'm designing a UI at the moment, and I have a situation where I have a QLineEdit which I need to only accept integers.
I know how to set the validator to use QIntValidator in code. But I'd like to do this in the designer.
How can I set the QLineEdit's validator when using the designer?
Note: I don't want to use an input mask. An input mask and a validator function differently.
Are you asking how to do it 100% through designer, or for a widget that was designed in designer?
You're going to need to do it at the code level no matter what, there is no way to do it directly in designer - not all functionality is exposed to it.
Out of curiosity, why not use a QSpinBox if you're getting purely an integer? You could use a QSpinBox and set the buttonSymbols to NoButtons, and even specify a suffix & prefix of text if you want. The end result looks and acts almost exactly like a QLineEdit, however is geared specifically for integer values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.