0

I have a qml file, it looks like the below (created by 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.

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.

How would I go about doing that?

TrebledJ
  • 8,713
  • 7
  • 26
  • 48
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
  • 4
    QML is interpreted by Qt to generate graphics items. I don't think you can convert QML into Python. But, you can easily integrate this file into a python script : [http://pyqt.sourceforge.net/Docs/PyQt5/qml.html](http://pyqt.sourceforge.net/Docs/PyQt5/qml.html) – Dimitry Ernot Feb 19 '19 at 08:59
  • @RomhaKorev Thanks, you should make this an answer it is very good. – U13-Forward Feb 20 '19 at 02:53
  • Aside: I don't think the V-Play Qt Creator is any different from the normal Qt Creator except for the V-Play plugins (Getting Started and Live). I _think_ all you need is the V-Play source code to load the V-Play QML modules -- whether you're using the Qt Creator by V-Play or the one from Qt. If you can be able to get Python to work with QML... then I don't think V-Play will be a problem. – TrebledJ Feb 20 '19 at 12:17

1 Answers1

1

QML is interpreted by Qt to generate graphics items. I don't think you can convert QML into Python.

But, you can easily integrate this file into a python script : http://pyqt.sourceforge.net/Docs/PyQt5/qml.html

app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(QUrl('./main.qml'))
app.exec_()
Dimitry Ernot
  • 6,256
  • 2
  • 25
  • 37