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


Python QGraphicsView.setBackgroundBrush方法代码示例

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


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

示例1: QApplication

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setBackgroundBrush [as 别名]
    import sys

    app = QApplication(sys.argv)

    scene = QGraphicsScene()
    scene.setStickyFocus(True)

    for y in range(10):
        for x in range(10):
            proxy = CustomProxy(None, Qt.Window)
            proxy.setWidget(EmbeddedDialog())

            rect = proxy.boundingRect()

            proxy.setPos( x * rect.width()*1.05, y*rect.height()*1.05 )
            proxy.setCacheMode(QGraphicsItem.DeviceCoordinateCache)
            scene.addItem(proxy)

    scene.setSceneRect(scene.itemsBoundingRect())

    view = QGraphicsView(scene)
    view.scale(0.5, 0.5)
    view.setRenderHints(view.renderHints() | QPainter.Antialiasing  | QPainter.SmoothPixmapTransform)
    view.setBackgroundBrush(QBrush(QPixmap(':/No-Ones-Laughing-3.jpg')))
    view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
    view.show()
    view.setWindowTitle("Embedded Dialogs Demo")

    sys.exit(app.exec_())
开发者ID:death-finger,项目名称:Scripts,代码行数:31,代码来源:embeddeddialogs.py

示例2: QApplication

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setBackgroundBrush [as 别名]
if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)

    scene = QGraphicsScene()
    scene.setSceneRect(-500, -500, 1000, 1000)
    scene.setItemIndexMethod(QGraphicsScene.NoIndex)

    car = Car()
    scene.addItem(car)

    view = QGraphicsView(scene)
    view.setRenderHint(QPainter.Antialiasing)
    view.setBackgroundBrush(Qt.darkGray)
    view.setWindowTitle("Qt DBus Controlled Car")
    view.resize(400, 300)
    view.show()

    a = CarInterfaceAdaptor(car)
    connection = QDBusConnection.sessionBus()
    connection.registerObject('/Car', car)
    connection.registerService('org.example.CarExample')

    rc = app.exec_()

    # Make sure things get destroyed in the right order.
    del view

    sys.exit(rc)
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:32,代码来源:car.py

示例3: QApplication

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setBackgroundBrush [as 别名]
if __name__== '__main__':

    import sys
    import math

    app = QApplication(sys.argv)

    qsrand(QTime(0, 0, 0).secsTo(QTime.currentTime()))

    scene = QGraphicsScene(-200, -200, 400, 400)

    for i in range(10):
        item = ColorItem()
        angle = i*6.28 / 10.0
        item.setPos(math.sin(angle)*150, math.cos(angle)*150)
        scene.addItem(item)

    robot = Robot()
    robot.setTransform(QTransform.fromScale(1.2, 1.2), True)
    robot.setPos(0, -20)
    scene.addItem(robot)

    view = QGraphicsView(scene)
    view.setRenderHint(QPainter.Antialiasing)
    view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
    view.setBackgroundBrush(QColor(230, 200, 167))
    view.setWindowTitle("Drag and Drop Robot")
    view.show()

    sys.exit(app.exec_())
开发者ID:CarlosAndres12,项目名称:pyqt5,代码行数:32,代码来源:dragdroprobot.py

示例4: QApplication

# 需要导入模块: from PyQt5.QtWidgets import QGraphicsView [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsView import setBackgroundBrush [as 别名]
if __name__ == '__main__':

    import sys

    MouseCount = 7

    app = QApplication(sys.argv)
    qsrand(QTime(0,0,0).secsTo(QTime.currentTime()))

    scene = QGraphicsScene()
    scene.setSceneRect(-300, -300, 600, 600)
    scene.setItemIndexMethod(QGraphicsScene.NoIndex)

    for i in range(MouseCount):
        mouse = Mouse()
        mouse.setPos(math.sin((i * 6.28) / MouseCount) * 200,
                     math.cos((i * 6.28) / MouseCount) * 200)
        scene.addItem(mouse)

    view = QGraphicsView(scene)
    view.setRenderHint(QPainter.Antialiasing)
    view.setBackgroundBrush(QBrush(QPixmap(':/images/cheese.jpg')))
    view.setCacheMode(QGraphicsView.CacheBackground)
    view.setViewportUpdateMode(QGraphicsView.BoundingRectViewportUpdate)
    view.setDragMode(QGraphicsView.ScrollHandDrag)
    view.setWindowTitle("Colliding Mice")
    view.resize(400, 300)
    view.show()

    sys.exit(app.exec_())
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:32,代码来源:collidingmice.py


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