Qt-interest Archive, August 2006
how to invoke a method directly of unkown superclass?
Message 1 in thread
Hi,
I have a question about Qt 4.2. For a research
project, I am looking for the possiblity to augment Qt
with classes with context-aware features. I am stuck
on one problem:
I have a mixin class called "location_object".
Developers should be able to mix this with the Qt 4.2
framework classes. For example:
class location_graphical_item :
public location_object,
public QObject,
public QGraphicalItem
{
MACRO_INVOKE_EVENT_METHOD => overloads
QObject::event() and redirects to
location_object::event()
MARCO_REINVOKE_EVENT_METHOD => redirects to
QObject::event()
};
The MACRO_INVOKE_EVENT_METHOD overrides
QObject::event() method and redirects it's
implementation to location_object::event(). In this
method I want to invoke my own virtual method
location_event() IF AND ONLY IF the event is one of my
own user-defined events. In all other cases, I want to
give the event back to the Qt-framework to do it's
usual dispatching (because it must be a Qt-defined
event).
In this case, I could invoke QObject::event()
directly. BUT, the problem is that in other cases I
might have derived from QWidget or other classes that
reimplement the QObject::event()-method. Therefore, I
need a way to invoke the method on the first
superclass that reimplements QObject::event()
directly. I there any way to do this through the
Meta-information on classes and methods in Qt? Or does
somebody see another solution?
Thanks alot!
Andrej van der Zee
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
--
[ signature omitted ]
Message 2 in thread
Look into how the macros for for slots and signals work. You may find something there.
Also, MFC does this exact type of thing, and the MACRO you need takes in the base type name...
Scott
________________________________
From: Andrej van der Zee [mailto:mavdzee@xxxxxxxxxxx]
Sent: Tue 8/1/2006 8:31 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: how to invoke a method directly of unkown superclass?
Hi,
I have a question about Qt 4.2. For a research
project, I am looking for the possiblity to augment Qt
with classes with context-aware features. I am stuck
on one problem:
I have a mixin class called "location_object".
Developers should be able to mix this with the Qt 4.2
framework classes. For example:
class location_graphical_item :
public location_object,
public QObject,
public QGraphicalItem
{
MACRO_INVOKE_EVENT_METHOD => overloads
QObject::event() and redirects to
location_object::event()
MARCO_REINVOKE_EVENT_METHOD => redirects to
QObject::event()
};
The MACRO_INVOKE_EVENT_METHOD overrides
QObject::event() method and redirects it's
implementation to location_object::event(). In this
method I want to invoke my own virtual method
location_event() IF AND ONLY IF the event is one of my
own user-defined events. In all other cases, I want to
give the event back to the Qt-framework to do it's
usual dispatching (because it must be a Qt-defined
event).
In this case, I could invoke QObject::event()
directly. BUT, the problem is that in other cases I
might have derived from QWidget or other classes that
reimplement the QObject::event()-method. Therefore, I
need a way to invoke the method on the first
superclass that reimplements QObject::event()
directly. I there any way to do this through the
Meta-information on classes and methods in Qt? Or does
somebody see another solution?
Thanks alot!
Andrej van der Zee
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
--
[ signature omitted ]
Message 3 in thread
Yes adding the type of the direct base-class to the macro works fine (I
realized this just after I posted the email). Though, I prefer not to
burden the developer with this...
I will take a look at the slots and signals to see if this can be
circumvented...
Thanks alot!
Andrej
Scott Aron Bloom wrote:
>Look into how the macros for for slots and signals work. You may find something there.
>
>Also, MFC does this exact type of thing, and the MACRO you need takes in the base type name...
>
>Scott
>
>________________________________
>
>From: Andrej van der Zee [mailto:mavdzee@xxxxxxxxxxx]
>Sent: Tue 8/1/2006 8:31 AM
>To: qt-interest@xxxxxxxxxxxxx
>Subject: how to invoke a method directly of unkown superclass?
>
>
>
>Hi,
>
>I have a question about Qt 4.2. For a research
>project, I am looking for the possiblity to augment Qt
>with classes with context-aware features. I am stuck
>on one problem:
>
>I have a mixin class called "location_object".
>Developers should be able to mix this with the Qt 4.2
>framework classes. For example:
>
>class location_graphical_item :
> public location_object,
> public QObject,
> public QGraphicalItem
>{
> MACRO_INVOKE_EVENT_METHOD => overloads
>QObject::event() and redirects to
>location_object::event()
> MARCO_REINVOKE_EVENT_METHOD => redirects to
>QObject::event()
>};
>
>The MACRO_INVOKE_EVENT_METHOD overrides
>QObject::event() method and redirects it's
>implementation to location_object::event(). In this
>method I want to invoke my own virtual method
>location_event() IF AND ONLY IF the event is one of my
>own user-defined events. In all other cases, I want to
>give the event back to the Qt-framework to do it's
>usual dispatching (because it must be a Qt-defined
>event).
>
>In this case, I could invoke QObject::event()
>directly. BUT, the problem is that in other cases I
>might have derived from QWidget or other classes that
>reimplement the QObject::event()-method. Therefore, I
>need a way to invoke the method on the first
>superclass that reimplements QObject::event()
>directly. I there any way to do this through the
>Meta-information on classes and methods in Qt? Or does
>somebody see another solution?
>
>Thanks alot!
>
>Andrej van der Zee
>
>
>
>
>
>
>
>
>
>
>___________________________________________________________
>The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
>
>--
>To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
>List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>--
>To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
>List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>
>
--
[ signature omitted ]
Message 4 in thread
Andrej van der Zee [mailto:mavdzee@xxxxxxxxxxx] wrote:
> class location_graphical_item :
> public location_object,
> public QObject,
> public QGraphicalItem
> {
> MACRO_INVOKE_EVENT_METHOD => overloads
> QObject::event() and redirects to
> location_object::event()
> MARCO_REINVOKE_EVENT_METHOD => redirects to
> QObject::event()
> };
>
> The MACRO_INVOKE_EVENT_METHOD overrides
> QObject::event() method and redirects it's
> implementation to location_object::event(). In this
> method I want to invoke my own virtual method
> location_event() IF AND ONLY IF the event is one of my
> own user-defined events. In all other cases, I want to
> give the event back to the Qt-framework to do it's
> usual dispatching (because it must be a Qt-defined
> event).
I am not sure I understand your intention, but making
the location_object an event filter in its
location_graphical_item and filtering out the 'intersting'
messages might help.
Andre'
--
[ signature omitted ]
Message 5 in thread
Hi,
My intesions are writing an extension framework for Qt
that provides mixin classes that receive a new type of
events generated by client objects for sensor
capturing devices.
Nevertheless, I am new to Qt and was not aware of the
existence of event filters. I realize that event
filters are exactly what I was trying to implement
myself.
Thanks alot!
Andrej
--- André Pönitz <andre@xxxxxxx> wrote:
> Andrej van der Zee [mailto:mavdzee@xxxxxxxxxxx]
> wrote:
> > class location_graphical_item :
> > public location_object,
> > public QObject,
> > public QGraphicalItem
> > {
> > MACRO_INVOKE_EVENT_METHOD => overloads
> > QObject::event() and redirects to
> > location_object::event()
> > MARCO_REINVOKE_EVENT_METHOD => redirects to
> > QObject::event()
> > };
> >
> > The MACRO_INVOKE_EVENT_METHOD overrides
> > QObject::event() method and redirects it's
> > implementation to location_object::event(). In
> this
> > method I want to invoke my own virtual method
> > location_event() IF AND ONLY IF the event is one
> of my
> > own user-defined events. In all other cases, I
> want to
> > give the event back to the Qt-framework to do it's
> > usual dispatching (because it must be a Qt-defined
> > event).
>
> I am not sure I understand your intention, but
> making
> the location_object an event filter in its
> location_graphical_item and filtering out the
> 'intersting'
> messages might help.
>
> Andre'
>
> --
> To unsubscribe - send a mail to
> qt-interest-request@xxxxxxxxxxxxx with "unsubscribe"
> in the subject or the body.
> List archive and information:
> http://lists.trolltech.com/qt-interest/
>
>
___________________________________________________________
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
--
[ signature omitted ]