更新时间:2023-01-28 15:10:31
你可以通过捕捉回车/回车键自动选择行编辑的文本:
You can automatically select the text of the line edit by catching the return/enter key press:
class SelectCombo(QtWidgets.QComboBox):
def keyPressEvent(self, event):
# call the base class implementation
super().keyPressEvent(event)
# if return/enter is pressed, select the text afterwards
if event.key() in (QtCore.Qt.Key_Return, QtCore.Qt.Key_Enter):
self.lineEdit().selectAll()