Are you moving by mouse? I would look into trapping mouseDown, mouseMove and
mouseUp, and calling move() yourself.
________________________________
From: Douglas Scott <douglas.a.sc...@gmail.com>
To: interest@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?
Thanks.
-DS
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest