如何将qml文件从VPlay转换成python?

2024-06-30 12:25:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个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
        }
    }
}

我用Qt Designer创建了许多PyQt5应用程序,因此它是一个.ui文件,我可以通过pyuic5轻松地将其转换为python文件,但这是我第一次使用V-playqt Creator。在

所以现在我的问题是:

如何将其转换为python文件(.py),正如您在我创建了两个输入区域(AppTextField)的代码中看到的那样,我希望它成为一个python文件,这样我就可以添加在输入区域中相加数字的函数,我尝试了一些东西,但是都没有成功,我查看了这个文件,Developing Python applications in Qt Creator,还有其他一些,但是它们没有达到我的目标。在

我该怎么做呢?在


Tags: 文件thefromhttpsimportidplaywidth
1条回答
网友
1楼 · 发布于 2024-06-30 12:25:22

ql由Qt解释以生成图形项。我不认为您可以将QML转换为Python。在

但是,您可以轻松地将此文件集成到python脚本中:http://pyqt.sourceforge.net/Docs/PyQt5/qml.html

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

相关问题 更多 >