프로그래밍/Python
[PyQT] QLineEdit 숫자만 입력할 수 있게 하기
KRFile
2022. 2. 1. 20:10
def set_only_int(self):
self.onlyInt = QIntValidator()
self.QLineEdit.setValidator(self.onlyInt)
QMainWindow 가 상속되어 있는 Class에서 다음과 같이 코드 2줄 실행하면 됩니다.
저는 함수로 호출해서 함수로 묶어놨습니다.
QLineEdit 부분에 사용하는 QLineEdit의 객체 이름을 입력해주세요.
<참고>
https://stackoverflow.com/questions/13422995/set-qlineedit-to-accept-only-numbers
Set QLineEdit to accept only numbers
I have a QLineEdit where the user should input only numbers. So is there a numbers-only setting for QLineEdit?
stackoverflow.com
https://stackoverflow.com/questions/15829782/how-to-restrict-user-input-in-qlineedit-in-pyqt
How to restrict user input in QLineEdit in pyqt
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
stackoverflow.com
(원문)