[Solved]Hierarchy of Event



  • I am building an application, the application has a Qframe in it, and the QFrame again have a QWidget in it. I want to know the sequence in which the events are called? Is the event from the QFrame is called first or the event from the QWidget called first?



  • AFAIK, QFrame Doesn't expose any Events directly because QFrames are supposed to be used as container for other Widgets. Moreover, If you want to handle events in QFrame, then you have to derive a class from it and you can use the events. Have you derived a class for QFrame and used any events there? If No, Then the Events from the QWidget is handled first.



  • Events are send directly to the object they are for. Only if the target object does not handle the event, the event is send to it's parent object. So, if an event is for the QWidget, the QWidget will get the event first. If needed the event is then send to first the parent QFrame, and then the grantparent QFrame.

    That is, unless you install an event filter...



  • Thanks for the reply :)



  • What hierarchy is followed in case of event filters?



  • At every step along the way of processing the event, one or more event filters may have been installed. The event is send to the event filters before it is send to the target object. Depending on the result of the filter, the event may be blocked from arriving at the target object. AFAIK, the event filters are called in the reverse order they have been installed, so the last installed filter is offered the event first.

    However, note that just like the event method, the eventFilter method is virtual. So, several implementations of this method in the class hierarchy may be involved for every call to it. A well-designed event filter would by default call it's base class implementation, at least for events not handled in the implementation of the current class.



  • Thanks Andre.... :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.