Search code examples
qt4lost-focus

In Qt4 is there a way to know from inside a widget if the focus has been lost?


I am trying to design a couple of simple widgets in order to get a better knowledge of Qt 4. (This is my first attempt at desktop programming - coming from a background of web development)

One of these widgets is formed from a label, and a tool window which pops up when the label is clicked.

My question is related to a method for the original widget to know when it loses mouses focus (ie, the user clicked somewhere else than inside the pop-up or the label) so it can hide the pop-up.


Solution

  • There are focusInEvent and focusOutEvent events. You can override these to get notified about focus changes.