You asked for an API, you got an API. If you want a signal, ask for a signal

A suitable signal might be QApplication::focusChanged.