2

I am making a PyQt5 application. I want to restrict the user to be able to enter only a single character in a QLineEdit object. Is this possible? If so, how?

Thanks in advance. :)

Nobody
  • 53
  • 11

1 Answers1

5

QLineEdit has the maxLength property.

setMaxLength()

Sets the maximum number of characters for input

e1 = QLineEdit()
e1.setMaxLength(1)
ncica
  • 7,015
  • 1
  • 15
  • 37