I have a QComboBox that is tied to database VARCHAR(45) field.
The QComboBox dropdown list provides a set of default values but it is EDIT enabled and user can enter anything in it.
I want to limit the user entry length to max of 45 chars
QComboBox does not have a setMaxLength(int) like QLineEdit does.
Anyone have any suggestions?
self.myDropDown = QComboBox()
self.myDropDown.setEditable(True)
Thanks
If a combo-box is editable, its lineEdit
method will give access to its line-edit widget:
self.myDropDown = QComboBox()
self.myDropDown.setEditable(True)
self.myDropDown.lineEdit().setMaxLength(45)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.