Reputation: 61
These are the 2 questions(both can be solved by InputMask?)
I'm not sure how I can implement the first part in real-time,i.e., the user types a max of 16, nothing beyond 16 appears.
This is my code(not working) for the 2nd part of the question:
self.onlyInt = QIntValidator()
self.lineEdit_15.setValidator(self.onlyInt)
det15=str(self.lineEdit_15.text())
list_val.append(det15)
Upvotes: 2
Views: 5688
Reputation: 243965
To solve the first question we only have to establish a maximum size:
self.lineedit_15.setMaxLength(16)
In contrast the second QIntValidator question only works up to a maximum equal to 2147483647
since it is the maximum integer: 2**31-1, The solution is to use regular expressions:
rx = QRegExp("\d+")
self.lineedit_15.setValidator(QRegExpValidator(rx))
Upvotes: 2