本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsView.update方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsView.update方法的具体用法?Python QGraphicsView.update怎么用?Python QGraphicsView.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsView
的用法示例。
在下文中一共展示了QGraphicsView.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import update [as 别名]
class MainWindow(QMainWindow):
InsertTextButton = 10
def __init__(self):
super(MainWindow, self).__init__()
self.createActions()
self.createMenus()
self.createToolBox()
self.scene = DiagramScene(self.itemMenu)
self.scene.setSceneRect(QRectF(0, 0, 5000, 5000))
self.scene.itemInserted.connect(self.itemInserted)
self.scene.textInserted.connect(self.textInserted)
self.scene.itemSelected.connect(self.itemSelected)
self.createToolbars()
layout = QHBoxLayout()
layout.addWidget(self.toolBox)
self.view = QGraphicsView(self.scene)
layout.addWidget(self.view)
self.widget = QWidget()
self.widget.setLayout(layout)
self.setCentralWidget(self.widget)
self.setWindowTitle("Diagramscene")
def backgroundButtonGroupClicked(self, button):
buttons = self.backgroundButtonGroup.buttons()
for myButton in buttons:
if myButton != button:
button.setChecked(False)
text = button.text()
if text == "Blue Grid":
self.scene.setBackgroundBrush(QBrush(QPixmap(':/images/background1.png')))
elif text == "White Grid":
self.scene.setBackgroundBrush(QBrush(QPixmap(':/images/background2.png')))
elif text == "Gray Grid":
self.scene.setBackgroundBrush(QBrush(QPixmap(':/images/background3.png')))
else:
self.scene.setBackgroundBrush(QBrush(QPixmap(':/images/background4.png')))
self.scene.update()
self.view.update()
def buttonGroupClicked(self, id):
buttons = self.buttonGroup.buttons()
for button in buttons:
if self.buttonGroup.button(id) != button:
button.setChecked(False)
if id == self.InsertTextButton:
self.scene.setMode(DiagramScene.InsertText)
else:
self.scene.setItemType(id)
self.scene.setMode(DiagramScene.InsertItem)
def deleteItem(self):
for item in self.scene.selectedItems():
if isinstance(item, DiagramItem):
item.removeArrows()
self.scene.removeItem(item)
def pointerGroupClicked(self, i):
self.scene.setMode(self.pointerTypeGroup.checkedId())
def bringToFront(self):
if not self.scene.selectedItems():
return
selectedItem = self.scene.selectedItems()[0]
overlapItems = selectedItem.collidingItems()
zValue = 0
for item in overlapItems:
if (item.zValue() >= zValue and isinstance(item, DiagramItem)):
zValue = item.zValue() + 0.1
selectedItem.setZValue(zValue)
def sendToBack(self):
if not self.scene.selectedItems():
return
selectedItem = self.scene.selectedItems()[0]
overlapItems = selectedItem.collidingItems()
zValue = 0
for item in overlapItems:
if (item.zValue() <= zValue and isinstance(item, DiagramItem)):
zValue = item.zValue() - 0.1
selectedItem.setZValue(zValue)
def itemInserted(self, item):
self.pointerTypeGroup.button(DiagramScene.MoveItem).setChecked(True)
self.scene.setMode(self.pointerTypeGroup.checkedId())
self.buttonGroup.button(item.diagramType).setChecked(False)
#.........这里部分代码省略.........