How to restrict user input in QLineEdit in pyqt
pyqt4, python, qlineedit
Solution
you can use QValidator. It works like:
# from PyQt5.QtGui import QIntValidator
# from PyQt6.QtGui import QIntValidator
# allow only integers
onlyInt = QIntValidator()
onlyInt.setRange(0, 4)
lineEdit.setValidator(onlyInt)
Problem
I have a `QLineEdit` and i want to restrict `QLineEdit` to accept only integers. It should work like inputmask. But I dont want to use `inputmask`, because if user clicks on `QLineEdit` cursor will be at the position where mouse was clicked. and user need to navigate to 0 position and type what eve he wants. Is there any alternate for this.