当前位置: 首页>>代码示例>>Python>>正文


Python QGraphicsWidget.mouseMoveEvent方法代码示例

本文整理汇总了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)
开发者ID:RachitKansal,项目名称:orange3,代码行数:30,代码来源:editlinksdialog.py

示例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)
开发者ID:PrimozGodec,项目名称:orange3,代码行数:49,代码来源:editlinksdialog.py


注:本文中的AnyQt.QtWidgets.QGraphicsWidget.mouseMoveEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。