access to event when an object is dinamically created
Hi,
it's strange, but I have a very basic question but I don't find the answer :S
if you create something, like for instance:
How I can access to its events? In my case, I would like to execute code when painting is called, so far I've subclased the paint event but for the first time I'm not subclassing anything.
thanks!
Re: access to event when an object is dinamically created
You have two options:
1. Subclass QGraphicsPixmapItem and override the event methods you want
2. Install an event filter on the object - see http://doc.trolltech.com/4.6/qobject...allEventFilter on how to do it.
Re: access to event when an object is dinamically created
thanks! that was what I was searching for.
Re: access to event when an object is dinamically created
uop, sorry, I just have seen now that a QGraphicsItem is not a QObject, so install the event filter is not allowed.
the only thing I see is QGraphicsItem::installSceneEventFilter, but I need to filter the events of one QGraphicsPixmapItem in one QObject, not one graphics item into another.
Am I wrong? or do I have any other possibility than subclass?
Re: access to event when an object is dinamically created
Sorry, I forgot that QGrphicsItems are not QObjects.
I think the easiest way would be to subclass QGraphicsPixmapItem and deal with the events there.