35
The simplest way is to connect a slot to the QApplication::focusChanged signal.
QWidget::setFocus() is slot, not signal. You can check if QLineEdit is in focus with focus property. QLineEdit emits signals when text is changed or edited, see documentation.