[PyQt] Defining hotspots on a picture

Rabson, Hugo SPC MIL USA USARPAC hugo.rabson at us.army.mil
Thu Sep 24 00:42:29 BST 2009


I'm trying to populate a QGraphicsView.scene() with user-adjustable
boxes. In theory, the QGraphicsView will display a picture to display on
the scene, then the scene will let the user draw boxes on top of that
scene. I'm trying to find a way to make those boxes adjustable.

Chapter 12 of Mark Summerfield's book has some sample code but it
doesn't permit adjustment of a box after it is dropped onto the picture.

-Hugo

P.S. My sample code (ugly):-

from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
app = QApplication(sys.argv)
app = QApplication(sys.argv)
graphicsview = QGraphicsView()
graphicsview.setDragMode(QGraphicsView.RubberBandDrag)
scene = QGraphicsScene(graphicsview)
graphicsview.setScene(scene)
scene.clear()
# TODO - use QPixmap to import a picture here ...
graphicsview.show()
box = scene.addBox(QBoxF(....)) # FIXME - this is not real code
txt - scene.addText("inside")
txt.setPos(50,50)
# ... Somehow make the box user-adjustable





More information about the PyQt mailing list