When you click OK, Cancel, and other buttons on the form, the slot function of the button is preceded by the Qlineedit editingfinished () signal
This can lead to many problems, such as clicking the Close button, the form's closeevent is rewritten to be hidden, then the Qlineedit focusoutevent event triggers the editingfinished () signal, This signal connection slot function is used to check the legality of Qlineedit, the law pop-up hint form, so that Qlineedit focusoutevent will be triggered ... The back is the infinite loop (this time you cry to t_t)
Solution: Customize a Qlineedit, and override Focusoutevent
public QLineEdit{ Q_OBJECTpublic: MyLineEdit0) : QLineEdit(parent) {} ~MyLineEdit(){}protected: virtualvoidfocusOutEvent(QFocusEvent * e) { if (e->reason() == Qt::ActiveWindowFocusReason) { return; } else { QLineEdit::focusOutEvent(e); } }};
Considerations for event-triggered scenarios with Qlineedit in QT forms