本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsItem.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsItem.isSelected方法的具体用法?Python QGraphicsItem.isSelected怎么用?Python QGraphicsItem.isSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsItem
的用法示例。
在下文中一共展示了QGraphicsItem.isSelected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: itemChange
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import isSelected [as 别名]
def itemChange(self, change, value):
# Move selected nodes and edges to the front, untill unselected
if change == QGraphicsItem.ItemSelectedChange:
if QGraphicsItem.isSelected(self):
#Unselected (since the flag is not updated yet)
self.setZValue(0)
self.setZValueEdges(1)
else:
#Selected
self.setZValue(4)
self.setZValueEdges(5)
#If the position of the node changes -> calculate position change
#and move edges with the node
newPos = value
if change == QGraphicsItem.ItemPositionChange:
if self.snappingIsOn:
newPos = self.snapToGrid(newPos)
posChange = newPos - self.lastPos
# Due to the grid snapping, only process when node actually moved
if not posChange.isNull():
self.moveEdges(posChange)
self.lastPos = newPos
self.widget.editNodePosition(self.nodeName, newPos)
return super(Node, self).itemChange(change, newPos)
示例2: hoverMoveEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import isSelected [as 别名]
def hoverMoveEvent(self, event):
#Don't execute when the nodeBody is selected in order to prevent unselecting the nodeBody
if not QGraphicsItem.isSelected(self):
self.mouseIsOnIO(event.pos())
super().hoverMoveEvent(event)
self.update()
#Must be done after super().mousePressEvent(event) in order to
#flag the node again after clicking on an input/output
self.setFlag(QGraphicsItem.ItemIsSelectable, True)
self.setFlag(QGraphicsItem.ItemIsMovable, True)
示例3: paintNodeBody
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import isSelected [as 别名]
def paintNodeBody(self, painter, lod):
painter.setPen(Qt.black)
#Subtle gradient
if lod > 0.2:
gradient = QLinearGradient(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
gradient.setColorAt(0, self.nodeBodyColor)
gradient.setColorAt(1, self.nodeBodyColorGradient)
brush = QBrush(gradient)
else:
brush = QBrush(self.nodeBodyColor)
if self.hover:
brush = QBrush(self.nodeBodyColorHover)
if QGraphicsItem.isSelected(self):
brush = QBrush(self.nodeBodyColorSelected)
painter.setBrush(brush)
if lod > 0.1:
painter.drawRoundedRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight, 10, 5)
else:
painter.drawRect(0, 0, self.nodeBodyWidth, self.nodeBodyHeight)
示例4: paintEdge
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsItem import isSelected [as 别名]
def paintEdge(self, painter, lod):
pen = QPen(Qt.black)
pen.setWidth(1)
pen.setCapStyle(Qt.RoundCap)
brush = QBrush(self.edgeColor)
if self.hover:
#pen.setColor(self.edgeColorHover)
brush.setColor(self.edgeColorHover)
if QGraphicsItem.isSelected(self):
#pen.setColor(self.edgeColorSelected)
brush.setColor(self.edgeColorSelected)
painter.setPen(pen)
painter.setBrush(brush)
edgePath = self.getEdgePath()
edgePath = edgePath.simplified()
painter.drawPath(edgePath)
if lod > 0.4:
self.drawPCRates(painter)