PDA

View Full Version : Custom QEvents not propagating to the top widget



Bakuriu
5th November 2009, 21:06
I've noticed that the custom QEvents(QEvents subclasses or simply events created with a User-type) are not propagated to the top widget...
This is a pain in the neck for me since if i don't want to do something like:

par = self.parent().parent().parent().parent()...so on...
qApp.postEvent(par,event)
(I'm writing using python, translate "self" with "this" and "." with -> or :: and it's the same as C++ code)

I thought that every QWidget subclass wouldn't accept User-type QEvents since if they do so they block the propagation of the event doing nothing(which is completely useless...)

Any (other) solution for this?

Bakuriu
6th November 2009, 13:33
Maybe i couldn't make me understand...

bool QWidget::event ( QEvent * event ) [virtual protected]

This is the main event handler; it handles event event. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event() will call the specialized handlers such as mousePressEvent(); otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

tell me why the above documentations is completely wrong.
The QEvent is accepted even if it isn't recognized and this is a big misfeature of qt(since it seems like it doesn't work the way the documentation tells...)