[Qt-interest] QgraphicsScene: best way to manage events
Christian Gagneraud
cgagneraud at techworks.ie
Thu Nov 25 01:02:35 CET 2010
Hi all,
I'm trying to implement a kind of drawing tool.
The user simply select the current tool (select, move, edit; draw
circle, rectangle, ...) from the main toolbar, and then
press/move/release the mouse depending on how this tool works.
I have sub-classed the scene, and I have a "Tool" base class.
As each tool will have to manage the mouse events its own way, I'm
looking at the best way to "forward" the mouse events from the scene
to the current tool, knowing that I would like later to be able to add
new tools via plug-ins (so the scene have to know only about the Tool
base class).
Should I let the tools register/unregister themselves as event filters
to the scene, or should I forward the events to the current tool in
the scene's event handler using postEvent()? Or are there any other
solutions for this typical use-case?
Regards,
Chris
--
Christian Gagneraud,
Electronics and software engineer
TechWorks Marine Ltd
4a, Park Lane
Dun Laoghaire, Co Dublin
Ireland
Tel: + 353 1 2365990
Fax: + 353 1 2365992
Web: www.techworks.ie
More information about the Qt-interest-old
mailing list