[Interest] QGraphicsItem: How to limit the position to which it is moved?
scorp1us at yahoo.com
Wed Apr 11 15:48:36 CEST 2012
Are you moving by mouse? I would look into trapping mouseDown, mouseMove and mouseUp, and calling move() yourself.
From: Douglas Scott <douglas.a.scott at gmail.com>
To: interest at qt-project.org
Sent: Wednesday, April 11, 2012 12:37 AM
Subject: [Interest] QGraphicsItem: How to limit the position to which it is moved?
I am new to QT 4.0. I have a QGraphicsItem subclass which I need to constrain its positioning when it is dragged on the screen by the mouse. For example, if another of these objects is visible on the screen, I want to be sure the x coordinate of the new one is always >= to the old. Also I want to have the option of constrained movement, where the object can only be moved vertically, if I choose.
I do not understand where I can intercept the setting of the object's position on the screen. I thought I could redefined QGraphicsItem::itemChange() and watch for ItemPositionChange and HasChanged -- but I never get any of these notifications. Given that setPos() is not overridable, where can I force limitations on my object's positioning?
Interest mailing list
Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest