PDA

View Full Version : signal/slot or subclassed event?



liqxpil
3rd November 2010, 11:30
hi all,

in my program i need to trigger an event whenever a subclassed QGraphicsItem is clicked, this event will affect lots of widgets including the parent scene of the item.. so should i re implement the event in the subclass or is it better to use a signal/slot combination?

high_flyer
3rd November 2010, 13:04
AFAIK, QGraphicsItem is not a QObject, so it should not be possible to use signals/slots with a QGraphicsItem, but you could use QGraphicsObject.

Nothing in what your wrote helps to decide which would be better.
As a thumb rule though, I would go for signals/slots as long as it is possible, and means less work than reimplemnting events.

wysota
3rd November 2010, 22:13
I would probably reimplement mouse events for the scene or reimplement the item to emit a signal and catch that in the scene. But the first approach is probably much simpler.

liqxpil
4th November 2010, 11:15
yup my question is which to do :)
if its not clear enough... i need to modify the items parent scene (add more items etc..) and other irrelevant widgets (not the scenes parent) based on the mouse events
i guess ill go with event re implementing since i subclassed already.. just not sure its the best thing to do..