[Interest] QGraphicsItem: How to limit the position to which it is moved?

Jason H 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?

Thanks.

-DS

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120411/fd8fc9a3/attachment.html>


More information about the Interest mailing list