python - How to restrict user input in QLineEdit in pyqt -


i have qlineedit , want restrict qlineedit accept integers. should work inputmask. dont want use inputmask, because if user clicks on qlineedit cursor @ position mouse clicked. , user need navigate 0 position , type eve wants.

is there alternate this.

you can use exception handling validating this:

number = self.ui.number_lineedit.text() try:     number = int(number) except exception:     qtgui.qmessagebox.about(self, 'error','input can number')     pass 

you can use validators validate input strings.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -