我正在制作一个 PyQt5 应用程序。我想限制用户只能在 QLineEdit 对象中输入单个字符。这可能吗?如果是这样,怎么办?
提前致谢。 :)
最佳答案
QLineEdit 具有 maxLength 属性。
setMaxLength()
Sets the maximum number of characters for input
e1 = QLineEdit()
e1.setMaxLength(1)
关于python - 将 QLineEdit 输入限制为单个字符 PyQt5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58589703/