As you pointed out, there are no signals for this function. You have two main options.
Option 1 - Subclass:
class FocusEmittingButton(QPushButton):
Then you can connect to this signal in the client code. Additionally, if necessary, you can use the Promote To constructor to promote each button to a FocusEmittingButton type. You will only need to subclass once, and then make sure that the different buttons are of the same type.
Option 2 - use QApplication.focusChanged
You can also use QApplication.focusChanged(oldQWidget, newQWidget) . By doing so, you do not need to subclass and override focus events. Instead, you connect to the QApplication.focusChanged signal, and then respond in the handler.
source share