[Qt-interest] Passing custom Events from Child to Parent.
Andre Somers
andre at familiesomers.nl
Tue Dec 1 16:12:10 CET 2009
Nitin Mahajan wrote:
> --- On Tue, 1/12/09, Andre Somers <andre at familiesomers.nl> wrote:
>
>
>> From: Andre Somers <andre at familiesomers.nl>
>> Subject: Re: [Qt-interest] Passing custom Events from Child to Parent.
>> To: "Qt-interest" <qt-interest at trolltech.com>
>> Date: Tuesday, 1 December, 2009, 5:30 PM
>> Nitin Mahajan wrote:
>>
>>> I need to pass some custom events from a child to
>>>
>> parent. The parent, handles all such custom events
>> separately.
>>
>>> I think in this case it would be safest / best to get
>>>
>> a custom event type for each event by calling
>> QEvent::registerEventType().
>>
>>> Now the question is, Whats the best way to communicate
>>>
>> these custom event types to the child?
>>
>>> regards
>>>
>>> -Nitin
>>>
>>>
>>>
>> I guess that depends on who decides who handles what. If
>> the child
>> itself decides, you should probably pass the event up
>> yourself. If the
>> parent should decide, I'd simply install an event filter on
>> the children
>> and intercept the events before they arrive at the child.
>>
>>
> I meant, how can the parent communicate to the child that these are the custom events it can handle. Thus the child can send these custom events.
> For example Parent can be the demo browser and child can be a plug-in widget.
>
Any way you like?
As you are not clear on who decides who handles what, there is no
defnitive answer here. If the parent can decide for itself, I'd just use
an event filter. You let the parent handle the events it can/wants, and
pass the rest on to the child. If you want the child to decide, you can
either have the parent pass some kind of list with handled types to the
child and only pass up the event types it knows the parent can handle,
or just pass up *all* events to the parent, and have the child wait and
see if the event is handled by the parent or not.
André
More information about the Qt-interest-old
mailing list