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


Python QQuickView.setProperty方法代码示例

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


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

示例1: View

# 需要导入模块: from PyQt5.QtQuick import QQuickView [as 别名]
# 或者: from PyQt5.QtQuick.QQuickView import setProperty [as 别名]
class View(object):

    shapes = ["rectangle", "ellipse", "image"]
    edgetypes = ["line", "curve"]

    def __init__(self):
        self._controller = Controller(self)
        self._gui = QGuiApplication(sys.argv)

        self._qml_dir = os.path.dirname(os.path.realpath(__file__))
        self._main = QQuickView()
        self._main.setResizeMode(QQuickView.SizeRootObjectToView)
        self._main.setSource(QUrl(self._qml_dir + '/main.qml'))

        self._main.rootObject().create_node.connect(
            self._controller.create_node)
        self._main.rootObject().mouse_position.connect(
            self._controller.mouse_position)
        self._main.rootObject().save.connect(
            self._controller.save)
        self._main.rootObject().load.connect(
            self._controller.load)
        self._main.rootObject().lose_focus.connect(
            self._controller.lose_focus)
        self._main.rootObject().node_color_sel.connect(
            self._controller.node_color_sel)
        self._main.rootObject().edge_color_sel.connect(
            self._controller.edge_color_sel)
        self._main.rootObject().workspace_height_changed.connect(
            self._controller.workspace_height_changed)
        self._main.rootObject().workspace_width_changed.connect(
            self._controller.workspace_width_changed)
        self._main.rootObject().edge_type_sel.connect(
            self._controller.edge_type_sel)
        self._main.rootObject().node_shape_sel.connect(
            self._controller.node_shape_sel)
        self._main.rootObject().clear_workspace.connect(
            self._controller.clear_workspace)
        self._main.rootObject().node_width_changed.connect(
            self._controller.node_width_changed)
        self._main.rootObject().node_height_changed.connect(
            self._controller.node_height_changed)
        self._main.rootObject().node_text_color_sel.connect(
            self._controller.node_text_color_sel)
        self._main.rootObject().node_text_size_changed.connect(
            self._controller.node_text_size_changed)
        self._main.rootObject().edge_thickness_changed.connect(
            self._controller.edge_thickness_changed)
        self._main.rootObject().show_edge_controls.connect(
            self._controller.show_edge_controls)
        self._main.rootObject().hide_edge_controls.connect(
            self._controller.hide_edge_controls)
        self._main.rootObject().exporting.connect(
            self._controller.exporting)
        self._main.setProperty(
            "width", self._controller.project.workspace_width)
        self._main.setProperty(
            "height", self._controller.project.workspace_height)
        self._main.show()

    def run(self):
        return self._gui.exec_()

    def create_node(self, node):
        # Creates new node from source QML and puts it inside of main window
        qml_node = QQuickView(QUrl(self._qml_dir + '/shapes/' +
                                   self.shapes[node.shape] + '.qml'),
                              self._main)

        workspace = self._main.rootObject().findChild(QQuickItem, "workspace")

        # Sets all properties
        qml_node.rootObject().setProperty("parent", workspace)
        qml_node.rootObject().setProperty("objectId", str(node.id))
        qml_node.rootObject().setProperty("background",
                                          str(node.background))
        qml_node.rootObject().setProperty("width", str(node.width))
        qml_node.rootObject().setProperty("height", str(node.height))
        qml_node.rootObject().setProperty("text", str(node.text.text))
        qml_node.rootObject().setProperty("textFont", str(node.text.font))
        qml_node.rootObject().setProperty("textSize", str(node.text.size))
        qml_node.rootObject().setProperty("textColor", str(node.text.color))

        # Sets drag boundaries
        qml_node.rootObject().setProperty("workspaceWidth",
                                          str(workspace.property("width")))
        qml_node.rootObject().setProperty("workspaceHeight",
                                          str(workspace.property("height")))

        # Signal connection
        qml_node.rootObject().node_delete.connect(
            self._controller.node_delete)
        qml_node.rootObject().node_text_changed.connect(
            self._controller.node_text_changed)
        qml_node.rootObject().node_position_changed.connect(
            self._controller.node_position_changed)
        qml_node.rootObject().node_connect.connect(
            self._controller.node_connect)
        qml_node.rootObject().node_focus.connect(
            self._controller.node_focus)
#.........这里部分代码省略.........
开发者ID:LukasSlouka,项目名称:MindMapper,代码行数:103,代码来源:__init__.py


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