I'm using Python 2.7 and PyQt4. I am trying to have a half-circle object that is a QGraphicsItem. I want to be able to move it using the mouse, by clicking and dragging. I can create the object and move it around with the mouse by setting the flag ItemIsMovable. Now the half-circle moves around freely but I want it to move just around the fixed central point. It is difficult to describe, but it should be something similar to a dial. How can I accomplish this?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- QML: Cannot read property 'xxx' of undefin
- How to get the background from multiple images by
- Evil ctypes hack in python
you can use QGraphicsItem::mouseMoveEvent event to track item's movements within the scene and correct its position once it's moved off the restricted area. Pls, check if an example below would work for you:
hope this helps, regards