我在一个继承自QGraphicsObject的类中放入了一个简单的QRectF。我希望此矩形区域通过鼠标拖动事件。i、 现在,我已经点击并拖动移动矩形。但是,我需要将该事件发送到后台,在那里我需要选择多个项目(默认情况下这是可能的)。为mouseevents设置属性WA_TransparentForMouseEvents似乎非常适合,但据我所知,这仅适用于QWidget
class GraphicsItem(QtWidgets.QGraphicsObject):
def __init__(self):
self._box = QtCore.QRectF(0, 0, 100, 100)
def mouseMoveEvent(self, event):
if (self._box.contains(event.pos()):
# set event transparency here
这可能吗? 谢谢
您可以为项目定义^{} 。我不知道你的GraphicsItem看起来像什么,但这里有一个通用的例子。另一项可以从
self._box
区域内选择或者,如果您特别想重新实现鼠标事件处理程序:
相关问题 更多 >
编程相关推荐