PyQt auto-space qlineedit characters
问题 Am having a qlineedit where a user types a verification code. I want to be able to space these numbers automatically every after 5 characters just like it is when activating windows where dashes are automatically added. For example 12345 67890 12345 67890 回答1: If the number of digits is fixed the best option is to use setInputMask(), in your case: if __name__ == '__main__': app = QApplication(sys.argv) le = QLineEdit() le.setInputMask(("ddddd "*4)[:-1]) le.show() sys.exit(app.exec_()) In the