C++写法:
void QLineEditEx::focusInEvent(QFocusEvent* event)
{
QLineEdit::focusInEvent(event);
QTimer::singleShot(0, this, &QLineEdit::selectAll);
}
Python写法:
class MyLineEdit(QLineEdit):
def __init__(self, parent):
super().__init__(parent)
def focusInEvent(self, evt):
super().focusInEvent(evt)
QTimer().singleShot(0, super().selectAll)