简体   繁体   English

如何将 QML 文件从 V-Play 转换为 python?

[英]How to convert a qml file from V-Play into python?

I have a qml file, it looks like the below (created by V-Play ):我有一个 qml 文件,如下所示(由V-Play创建):

import VPlayApps 1.0
import QtQuick 2.0

App {
    // You get free licenseKeys from https://v-play.net/licenseKey
    // With a licenseKey you can:
    //  * Publish your games & apps for the app stores
    //  * Remove the V-Play Splash Screen or set a custom one (available with the Pro Licenses)
    //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
    //licenseKey: "<generate one from https://v-play.net/licenseKey>"

    NavigationStack {

        Page {
            title: qsTr("My page")

        }

        AppTextField {
            id: appTextField
            x: 0
            y: 329
            width: 256
            height: 19
            anchors.centerIn: parent
        }

        AppTextField {
            id: appTextField1
            x: 0
            y: 329
            width: 256
            height: 19
            anchors.verticalCenterOffset: 50
            anchors.centerIn: parent
        }

        Text {
            id: text1
            x: 0
            y: 620
            width: 24
            height: 20
            text: qsTr("A")
            font.pixelSize: 25
            anchors.horizontalCenter: appTextField1.horizontalCenter
        }

        AppButton {
            id: button
            x: 0
            y: 575
            width: 24
            height: 20
            text: qsTr("Click me please!")
            anchors.horizontalCenter: appTextField1.horizontalCenter
        }
    }
}

I created many PyQt5 apps, by Qt Designer, so it would be a .ui file which I could convert easily into a python file by pyuic5 , but this is now the first time I used V-Play Qt Creator.我通过 Qt Designer 创建了许多 PyQt5 应用程序,因此它是一个 .ui 文件,我可以通过pyuic5轻松将其转换为 python 文件,但这是我第一次使用 V-Play Qt Creator。

So now my question is:所以现在我的问题是:

How do I convert this into a python file (.py), as you see in the code I created two input areas ( AppTextField ), I would like it to become a python file so I can add the function which adds up the numbers in the input areas, I tried some stuff, but none of them worked, I viewed this one, Developing Python applications in Qt Creator , and some more, but they don't achieve my goal.如何将其转换为 python 文件 (.py),正如您在我创建两个输入区域 ( AppTextField ) 的代码中看到的,我希望它成为一个 python 文件,以便我可以添加将数字相加的函数输入区域,我尝试了一些东西,但没有一个起作用,我查看了这个, 在 Qt Creator 中开发 Python 应用程序,还有一些,但它们没有实现我的目标。

How would I go about doing that?我该怎么做?

QML is interpreted by Qt to generate graphics items. QML 由 Qt 解释以生成图形项。 I don't think you can convert QML into Python.我认为您无法将 QML 转换为 Python。

But, you can easily integrate this file into a python script : http://pyqt.sourceforge.net/Docs/PyQt5/qml.html但是,您可以轻松地将此文件集成到 python 脚本中: http : //pyqt.sourceforge.net/Docs/PyQt5/qml.html

app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl('./main.qml'))
app.exec_()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM