本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsWidget.mouseMoveEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsWidget.mouseMoveEvent方法的具体用法?Python QGraphicsWidget.mouseMoveEvent怎么用?Python QGraphicsWidget.mouseMoveEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsWidget
的用法示例。
在下文中一共展示了QGraphicsWidget.mouseMoveEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mouseMoveEvent
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsWidget [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsWidget import mouseMoveEvent [as 别名]
def mouseMoveEvent(self, event):
if event.buttons() & Qt.LeftButton:
downPos = event.buttonDownPos(Qt.LeftButton)
if not self.__tmpLine and self.__dragStartItem and \
(downPos - event.pos()).manhattanLength() > \
QApplication.instance().startDragDistance():
# Start a line drag
line = QGraphicsLineItem(self)
start = self.__dragStartItem.boundingRect().center()
start = self.mapFromItem(self.__dragStartItem, start)
line.setLine(start.x(), start.y(),
event.pos().x(), event.pos().y())
pen = QPen(Qt.black, 4)
pen.setCapStyle(Qt.RoundCap)
line.setPen(pen)
line.show()
self.__tmpLine = line
if self.__tmpLine:
# Update the temp line
line = self.__tmpLine.line()
line.setP2(event.pos())
self.__tmpLine.setLine(line)
QGraphicsWidget.mouseMoveEvent(self, event)
示例2: mouseMoveEvent
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsWidget [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsWidget import mouseMoveEvent [as 别名]
def mouseMoveEvent(self, event):
if event.buttons() & Qt.LeftButton:
downPos = event.buttonDownPos(Qt.LeftButton)
if not self.__tmpLine and self.__dragStartItem and \
(downPos - event.pos()).manhattanLength() > \
QApplication.instance().startDragDistance():
# Start a line drag
line = LinkLineItem(self)
start = self.__dragStartItem.boundingRect().center()
start = self.mapFromItem(self.__dragStartItem, start)
eventPos = event.pos()
line.setLine(start.x(), start.y(), eventPos.x(), eventPos.y())
pen = QPen(self.palette().color(QPalette.Foreground), 4)
pen.setCapStyle(Qt.RoundCap)
line.setPen(pen)
line.show()
self.__tmpLine = line
if self.__dragStartItem in self.sourceNodeWidget.channelAnchors:
for anchor in self.sinkNodeWidget.channelAnchors:
self.__updateAnchorState(anchor, [self.__dragStartItem])
else:
for anchor in self.sourceNodeWidget.channelAnchors:
self.__updateAnchorState(anchor, [self.__dragStartItem])
if self.__tmpLine:
# Update the temp line
line = self.__tmpLine.line()
maybe_anchor = find_item_at(self.scene(), event.scenePos(),
type=ChannelAnchor)
# If hovering over anchor
if maybe_anchor is not None and maybe_anchor.isEnabled():
target_pos = maybe_anchor.boundingRect().center()
target_pos = self.mapFromItem(maybe_anchor, target_pos)
line.setP2(target_pos)
else:
target_pos = event.pos()
line.setP2(target_pos)
self.__tmpLine.setLine(line)
QGraphicsWidget.mouseMoveEvent(self, event)