美文网首页
pip install PySide2

pip install PySide2

作者: 我的小小笔尖 | 来源:发表于2021-06-21 11:30 被阅读0次

    1. 虚拟环境下安装 PySide2

    https://pypi.org/project/PySide2/
    PySide2 5.15.2, Released: Nov 20, 2020
    provides access to the complete Qt 5.12+ framework.

    pip install PySide2
    

    安装成功提示:

    Installing collected packages: shiboken2, PySide2
    Successfully installed PySide2-5.15.2 shiboken2-5.15.2
    

    PySide2依赖Clang,可访问下面地址安装
    https://download.qt.io/development_releases/prebuilt/libclang/

    2. 小例子 Qt for Python Tutorial HelloQML

    更多示例:
    https://wiki.qt.io/Qt_for_Python/Tutorial

    view.qml

    import QtQuick 2.0
    
    Rectangle {
        width: 320
        height: 480
        color: "green"
    
        Rectangle {
            x:50; y:50
            width: 100
            height: 100
            color: "red"
         }
    
        Text {
            text: "Hello World"
            color: "#ffffff"
            font.pixelSize: 32
            anchors.centerIn: parent
        }
    }
    

    main.py

    from PySide2.QtWidgets import QApplication
    from PySide2.QtQuick import QQuickView
    from PySide2.QtCore import QUrl
    
    app = QApplication([])
    view = QQuickView()
    url = QUrl("view.qml")
    
    view.setSource(url)
    view.show()
    app.exec_()
    

    运行截图


    捕获.JPG

    相关文章

      网友评论

          本文标题:pip install PySide2

          本文链接:https://www.haomeiwen.com/subject/qkcyyltx.html