草庐IT

MousePressEvent

全部标签

python - MousePressEvent,QGraphicsView中的位置偏移

我在使用QGraphicsView和QGraphicsScene时遇到了一些困难。当我在场景中缩放/取消缩放并使用mousePressEvent创建项目时,我在该位置有一个偏移量。如何避免这种情况?event.pos()似乎是问题所在..fromPyQt4importQtCore,QtGuiclassgraphicsItem(QtGui.QGraphicsItem):def__init__(self):super(graphicsItem,self).__init__()self.rectF=QtCore.QRectF(0,0,10,10)defboundingRect(self):r