我有一个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 Play Qt。
所以现在我的问题是:
我如何将它转换为python (.py),正如您在代码中看到的,我创建了两个输入区域(AppTextField),我希望它成为一个python文件,这样我就可以添加函数将输入区域中的数字相加,我尝试了一些东西,但是它们都没有工作,我查看了这个输入区域,在Qt中开发Python应用程序和其他一些,但是它们没有达到我的目标。
我该怎么做?
发布于 2019-02-20 08:51:49
Qt解释QML以生成图形项。我认为您无法将QML转换为Python。
但是,您可以轻松地将该文件集成到python脚本中:http://pyqt.sourceforge.net/Docs/PyQt5/qml.html
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl('./main.qml'))
app.exec_()https://stackoverflow.com/questions/54761619
复制相似问题