我有一个使用QGraphicsView的pyside2gui。你知道吗
我使用setDragMode(QGraphicsView.ScrollHandDrag文件)使视图可拖动,但我使用viewport().setCursor覆盖光标(Qt.箭头光标)在mouseReleaseEvent上,以避免经常用张开的手代替正常的箭头光标。 这里解释:Changing the cursor in a QGraphicsView(用c++)
在GUI中还有一个带有QLabel的QGraphicsProxyWidget。将鼠标放置在ProxyWidget上时,viewport().setCursor(Qt.箭头光标)不起作用(调用了moseReleaseEvent,所以我知道调用了setCursor),当鼠标离开ProxyWidget时,会显示open hand光标而不是箭头光标。你知道吗
当鼠标放在QGraphicsView的所有其他位置时,一切都按预期工作。你知道吗
有人知道为什么当鼠标放在proxyWidget上时setCursor的行为不同吗?你知道吗
在QGraphicsView中:
def mouseReleaseEvent(self, event):
QGraphicsView.mouseReleaseEvent(self, event)
self.viewport().setCursor(Qt.ArrowCursor)
def infoBoxShow(self, edge, mouse_pos):
if self.info_box is None:
self.info_box = VardeInfoBox_v2.InfoBox()
self.info_box.corresponding_edge = edge
self.info_box.setPos(mouse_pos)
self.info_box.setInfoText(edge)
self.main_scene.addItem(self.info_box)
InfoBox(如您所见,我试图设置一些标志,但没有成功):
class InfoBox(QGraphicsItem):
Type = QGraphicsItem.UserType + 1
def __init__(self):
QGraphicsItem.__init__(self)
self.setFlag(QGraphicsItem.hover)
self.setZValue(4)
proxy = QGraphicsProxyWidget(self)
widget = QLabel("TEST!")
widget.setAttribute(Qt.WA_TransparentForMouseEvents)
widget.setWindowModality(Qt.NonModal)
proxy.setWidget(widget)
self.corresponding_edge = None
目前没有回答
相关问题 更多 >
编程相关推荐