tags:

views:

170

answers:

1

Hi,

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.

+1  A: 

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

Lukáš Lalinský
Yes, you are right.I had already tried the `focusOutEvent`... however after your reply I gave it more thought and made some changes to my previous test case.How I got it to work is by overwriting the showEvent of the pop-up window (by default Qt seems not to set the focus on it, even though it's raised and becomes to top of the window stack) and setting the focus manually. This means that now the `focusOutEvent` works for clicking outside the pop-up window (which previously didn't happen as the window didn't actually have focus).Thank you.
HabarNam