本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView.sceneRect方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.sceneRect方法的具体用法?Python QGraphicsView.sceneRect怎么用?Python QGraphicsView.sceneRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.sceneRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QNEMainWindow
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import sceneRect [as 别名]
class QNEMainWindow(QMainWindow):
def __init__(self, parent):
super(QNEMainWindow, self).__init__(parent)
quitAct = QAction("&Quit", self, shortcut="Ctrl+Q",
statusTip="Exit the application", triggered=self.close)
addAct = QAction("&Add", self, statusTip="Add a block", triggered=self.addBlock)
fileMenu = self.menuBar().addMenu("&File")
fileMenu.addAction(addAct)
fileMenu.addSeparator()
fileMenu.addAction(quitAct)
self.setWindowTitle("Node Editor")
self.scene = QGraphicsScene(self)
self.view = QGraphicsView(self)
self.view.setScene(self.scene)
self.view.setRenderHint(QPainter.Antialiasing)
self.setCentralWidget(self.view)
self.nodesEditor = QNodesEditor(self)
self.nodesEditor.install(self.scene)
block = QNEBlock(None)
self.scene.addItem(block)
block.addPort("test", 0, QNEPort.NamePort)
block.addPort("TestBlock", 0, QNEPort.TypePort)
block.addInputPort("in1");
block.addInputPort("in2");
block.addInputPort("in3");
block.addOutputPort("out1");
block.addOutputPort("out2");
block.addOutputPort("out3");
block = block.clone()
block.setPos(150,0)
block = block.clone()
block.setPos(150,150)
def addBlock(self):
import random
import math
block = QNEBlock(None)
self.scene.addItem(block)
names = ["Vin", "Voutsadfasdf", "Imin", "Imax", "mul", "add", "sub", "div", "Conv", "FFT"]
for i in range(0,math.floor(random.uniform(3,8))):
block.addPort(random.choice(names), random.random()>0.5)
block.setPos(self.view.sceneRect().center().toPoint())