So finally I've got it working:
- subclass QLayout for your needs
- find out if your QWidget "A" has any QLayout attached
- if yes: your QLayout should be of same kind, so you can reattach "A"'s children to it
- if not: great, just attach your custom layout
"A"->setLayout(myLayout);
- the subclassed myLayout needs some stuff to do the trick:
- reimplemented eventFilter() function
"A"->installEventFilter(myLayout);
- in the eventFilter:
if(event->type() == QEvent::Enter) grabKeyboard();
if(event->type() == QEvent::Leave) releaseKeyboard();
- ... all that event management you'd like to implement ...
The key to get it working was my misunderstanding of the Qt-docs regarding "installEventFilter". The "filterobject" is the object that wants to get all events, the monitored object is the one we'd like to get any events from. Then installation of the filter works like (and thinking about it makes it perfectly logical): monitoredObject->installEventFilter(filterobject);
.