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


Python QtCore.QRect方法代码示例

本文整理汇总了Python中Qt.QtCore.QRect方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QRect方法的具体用法?Python QtCore.QRect怎么用?Python QtCore.QRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Qt.QtCore的用法示例。


在下文中一共展示了QtCore.QRect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paint

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def paint(self, painter, option, index):
        painter.save()
        rect = option.rect
        font_matrics = QtGui.QFontMetrics(option.font)
        tester_name = index.data(model.DisplayRole)

        status = index.data(model.StatusRole)
        if status == model.Ready:
            icon = self.__ready_icon
        elif status == model.Success:
            icon = self.__success_icon
        elif status == model.Failure:
            icon = self.__failure_icon

        painter.fillRect(rect, self.getBackgroudColor(option, index))
        painter.drawPixmap(QtCore.QRect(rect.x() + 12, rect.y() + 2, 16, 16), icon)
        painter.drawText(rect.x() + 40, rect.y() + rect.height() * 0.5 + font_matrics.height() * 0.5 - 4, tester_name)

        painter.restore() 
开发者ID:sol-ansano-kim,项目名称:medic,代码行数:21,代码来源:delegate.py

示例2: _createPointerBoundingBox

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def _createPointerBoundingBox(pointerPos, bbSize):
    """
    generate a bounding box around the pointer.

    :param pointerPos: Pointer position.
    :type  pointerPos: QPoint.

    :param bbSize: Width and Height of the bounding box.
    :type  bbSize: Int.

    """
    # Create pointer's bounding box.
    point = pointerPos

    mbbPos = point
    point.setX(point.x() - bbSize / 2)
    point.setY(point.y() - bbSize / 2)

    size = QtCore.QSize(bbSize, bbSize)
    bb = QtCore.QRect(mbbPos, size)
    bb = QtCore.QRectF(bb)

    return bb 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:25,代码来源:nodz_utils.py

示例3: boundingRect

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def boundingRect(self):
        """
        The bounding rect based on the width and height variables.

        """
        width = height = self.parentItem().attrHeight / 2.0

        nodzInst = self.scene().views()[0]
        config = nodzInst.config

        x = - width / 2.0
        y = (self.parentItem().baseHeight - config['node_radius'] +
            (self.parentItem().attrHeight/4) +
             self.parentItem().attrs.index(self.attribute) * self.parentItem().attrHeight )

        rect = QtCore.QRectF(QtCore.QRect(x, y, width, height))
        return rect 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:19,代码来源:nodz_main.py

示例4: updateReroutes

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def updateReroutes(self, event, showPins=False):
        tolerance = 9 * self.currentViewScale()
        mouseRect = QtCore.QRect(QtCore.QPoint(event.pos().x() - tolerance, event.pos().y() - tolerance),
                                 QtCore.QPoint(event.pos().x() + tolerance, event.pos().y() + tolerance))
        hoverItems = self.items(mouseRect)
        self.hoveredReroutes += [node for node in hoverItems if isinstance(node, UINodeBase) and node.isReroute()]
        for node in self.hoveredReroutes:
            if showPins:
                if node in hoverItems:
                    node.showPins()
                else:
                    node.hidePins()
                    self.hoveredReroutes.remove(node)
            else:
                node.hidePins()
                self.hoveredReroutes.remove(node) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:18,代码来源:BlueprintCanvas.py

示例5: getItemsRect

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def getItemsRect(self, cls=QGraphicsItem, bSelectedOnly=False, bVisibleOnly=True):
        rectangles = []
        for item in self.scene().items():
            if isinstance(item, cls):
                if bVisibleOnly and not item.isVisible():
                    continue
                if bSelectedOnly and not item.isSelected():
                    continue

                rect = item.sceneBoundingRect().toRect()
                rectangles.append(rect)

        result = QtCore.QRect()

        for r in rectangles:
            result |= r

        return result 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:20,代码来源:CanvasBase.py

示例6: _initRubberband

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def _initRubberband(self, position):
        """
        Initialize the rubber band at the given position.

        """
        self.rubberBandStart = position
        self.origin = position
        self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
        self.rubberband.show() 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:11,代码来源:nodz_main.py

示例7: findPinNearPosition

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def findPinNearPosition(self, scenePos, tolerance=3):
        tolerance = tolerance * self.currentViewScale()
        rect = QtCore.QRect(QtCore.QPoint(scenePos.x() - tolerance, scenePos.y() - tolerance),
                            QtCore.QPoint(scenePos.x() + tolerance, scenePos.y() + tolerance))
        items = self.items(rect)
        pins = [i for i in items if isinstance(i, UIPinBase) and type(i) is not PinGroup]
        if len(pins) > 0:
            return pins[0]
        return None 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:11,代码来源:BlueprintCanvas.py

示例8: dragMoveEvent

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def dragMoveEvent(self, event):
        self.mousePos = event.pos()
        scenePos = self.mapToScene(self.mousePos)
        if self.dropCallback is not None:
            event.accept()
        elif event.mimeData().hasFormat('text/plain'):
            event.setDropAction(QtCore.Qt.MoveAction)
            event.accept()
            if self.tempnode:
                self.tempnode.setPos((self.tempnode.w / -2) + scenePos.x(), scenePos.y())
                mouseRect = QtCore.QRect(QtCore.QPoint(scenePos.x() - 1, scenePos.y() - 1),
                                         QtCore.QPoint(scenePos.x() + 1, scenePos.y() + 1))
                hoverItems = self.scene().items(mouseRect)
                for item in hoverItems:
                    if isinstance(item, UIConnection):
                        valid = False
                        for inp in self.tempnode.UIinputs.values():
                            if canConnectPins(item.source()._rawPin, inp._rawPin):
                                valid = True
                        for out in self.tempnode.UIoutputs.values():
                            if canConnectPins(out._rawPin, item.destination()._rawPin):
                                valid = True
                        if valid:
                            self.hoverItems.append(item)
                            item.drawThick()
                for item in self.hoverItems:
                    if item not in hoverItems:
                        self.hoverItems.remove(item)
                        if isinstance(item, UIConnection):
                            item.restoreThick()
                    else:
                        if isinstance(item, UIConnection):
                            item.drawThick()
        else:
            super(BlueprintCanvas, self).dragMoveEvent(event) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:37,代码来源:BlueprintCanvas.py

示例9: __init__

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def __init__(self, parent=None):
        super(PyFlow, self).__init__(parent=parent)
        self._modified = False
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.currentSoftware = ""
        self.edHistory = EditorHistory(self)
        self.edHistory.statePushed.connect(self.historyStatePushed)
        self.setWindowTitle(winTitle())
        self.undoStack = QUndoStack(self)
        self.setContentsMargins(1, 1, 1, 1)
        self.graphManager = GraphManagerSingleton()
        self.canvasWidget = BlueprintCanvasWidget(self.graphManager.get(), self)
        self.canvasWidget.setObjectName("canvasWidget")
        self.setCentralWidget(self.canvasWidget)
        self.setTabPosition(QtCore.Qt.AllDockWidgetAreas, QTabWidget.North)
        self.setDockOptions(QMainWindow.AnimatedDocks | QMainWindow.AllowNestedDocks)

        self.menuBar = QMenuBar(self)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 863, 21))
        self.menuBar.setObjectName("menuBar")
        self.setMenuBar(self.menuBar)
        self.toolBar = QToolBar(self)
        self.toolBar.setObjectName("toolBar")
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        self.setWindowIcon(QtGui.QIcon(":/LogoBpApp.png"))
        self._tools = set()
        self.currentTempDir = ""

        self.preferencesWindow = PreferencesWindow(self)

        self.setMouseTracking(True)

        self._lastClock = 0.0
        self.fps = EDITOR_TARGET_FPS
        self.tick_timer = QtCore.QTimer()
        self._currentFileName = ''
        self.currentFileName = None 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:40,代码来源:App.py

示例10: mouseMoveEvent

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def mouseMoveEvent(self, event):
        """
        Update tablet zoom, canvas dragging and selection.

        """
        # Zoom.
        if self.currentState == 'ZOOM_VIEW':
            offset = self.zoomInitialPos.x() - event.pos().x()

            if offset > self.previousMouseOffset:
                self.previousMouseOffset = offset
                self.zoomDirection = -1
                self.zoomIncr -= 1

            elif offset == self.previousMouseOffset:
                self.previousMouseOffset = offset
                if self.zoomDirection == -1:
                    self.zoomDirection = -1
                else:
                    self.zoomDirection = 1

            else:
                self.previousMouseOffset = offset
                self.zoomDirection = 1
                self.zoomIncr += 1

            if self.zoomDirection == 1:
                zoomFactor = 1.03
            else:
                zoomFactor = 1 / 1.03

            # Perform zoom and re-center on initial click position.
            pBefore = self.mapToScene(self.initMousePos)
            self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
            self.scale(zoomFactor, zoomFactor)
            pAfter = self.mapToScene(self.initMousePos)
            diff = pAfter - pBefore

            self.setTransformationAnchor(QtWidgets.QGraphicsView.NoAnchor)
            self.translate(diff.x(), diff.y())

        # Drag canvas.
        elif self.currentState == 'DRAG_VIEW':
            offset = self.prevPos - event.pos()
            self.prevPos = event.pos()
            self.verticalScrollBar().setValue(self.verticalScrollBar().value() + offset.y())
            self.horizontalScrollBar().setValue(self.horizontalScrollBar().value() + offset.x())

        # RuberBand selection.
        elif (self.currentState == 'SELECTION' or
              self.currentState == 'ADD_SELECTION' or
              self.currentState == 'SUBTRACT_SELECTION' or
              self.currentState == 'TOGGLE_SELECTION'):
            self.rubberband.setGeometry(QtCore.QRect(self.origin, event.pos()).normalized())

        super(Nodz, self).mouseMoveEvent(event) 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:58,代码来源:nodz_main.py

示例11: _getSelectionBoundingbox

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def _getSelectionBoundingbox(self):
        """
        Return the bounding box of the selection.

        """
        bbx_min = None
        bbx_max = None
        bby_min = None
        bby_max = None
        bbw = 0
        bbh = 0
        for item in self.scene().selectedItems():
            pos = item.scenePos()
            x = pos.x()
            y = pos.y()
            w = x + item.boundingRect().width()
            h = y + item.boundingRect().height()

            # bbx min
            if bbx_min is None:
                bbx_min = x
            elif x < bbx_min:
                bbx_min = x
            # end if

            # bbx max
            if bbx_max is None:
                bbx_max = w
            elif w > bbx_max:
                bbx_max = w
            # end if

            # bby min
            if bby_min is None:
                bby_min = y
            elif y < bby_min:
                bby_min = y
            # end if

            # bby max
            if bby_max is None:
                bby_max = h
            elif h > bby_max:
                bby_max = h
            # end if
        # end if
        bbw = bbx_max - bbx_min
        bbh = bby_max - bby_min
        return QtCore.QRectF(QtCore.QRect(bbx_min, bby_min, bbw, bbh)) 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:51,代码来源:nodz_main.py

示例12: __init__

# 需要导入模块: from Qt import QtCore [as 别名]
# 或者: from Qt.QtCore import QRect [as 别名]
def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.resize(600, 400)
        self.setWindowTitle("Preferences")
        self.centralWidget = QWidget(self)
        self.centralWidget.setObjectName("centralWidget")
        self.verticalLayout = QVBoxLayout(self.centralWidget)
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.verticalLayout.setObjectName("verticalLayout")
        self.splitter = QSplitter(self.centralWidget)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName("splitter")
        self.scrollArea = QScrollArea(self.splitter)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.scrollAreaWidgetContents = QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 497, 596))
        self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
        self.scrollArea.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
        self.verticalLayout_3 = QVBoxLayout(self.scrollAreaWidgetContents)
        self.verticalLayout_3.setContentsMargins(1, 1, 1, 1)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.verticalLayout_3.setSpacing(2)
        self.categoriesVerticalLayout = QVBoxLayout()
        self.categoriesVerticalLayout.setObjectName("categoriesLayout")
        spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.categoriesVerticalLayout.addItem(spacer)
        self.verticalLayout_3.addLayout(self.categoriesVerticalLayout)
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.scrollArea.setMinimumWidth(200)
        self.stackedWidget = QStackedWidget(self.splitter)
        self.stackedWidget.setObjectName("stackedWidget")
        self.stackedWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.verticalLayout.addWidget(self.splitter)
        self.setCentralWidget(self.centralWidget)
        self.splitter.setSizes([150, 450])
        self._indexes = {}
        self.categoryButtons = {}
        self.buttonsLay = QHBoxLayout()
        pbSavePrefs = QPushButton("SaveAsDefault")
        pbSavePrefs.clicked.connect(self.savePreferences)
        pbSaveAndClosePrefs = QPushButton("SaveAndClose")
        pbSaveAndClosePrefs.clicked.connect(self.saveAndClosePrefs)
        self.buttonsLay.addWidget(pbSavePrefs)
        self.buttonsLay.addWidget(pbSaveAndClosePrefs)
        self.categoriesVerticalLayout.addLayout(self.buttonsLay)

        self.tryCreateDefaults() 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:50,代码来源:PreferencesWindow.py


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