Currently working on a Python program that uses Qt Widgets from an .ui file to display an interactable GUI. However, i have not found a way to integrate the QQuickview widget to display any QML code, which i have read is possible.
I'm using PySide2 to convert the .ui file from Qt Designer and have both attempted to use the QQuickWidget found in Qt Designer, and manualy adding a QQuickView to the gridLayout in the .ui to no success.
The QQuickWidget i added in Qt Designer was, as far as i could tell transformed to a QWidget when run in python, so setSource(QUrl) or .load(QUrl) Made no sense when running the code.
My attempt at adding the QQuickView:
def connect_map_click(self):
# Function for handling the connect map button
engine = QQuickView()
ctx = engine.rootContext()
url = QUrl.fromLocalFile('QMLtest.qml')
engine.setSource(url)
container = QWidget.createWindowContainer(engine, self)
container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
engine.show()
self.window.grd_map.addWidget(container, 0, 0)
The QML file:
import QtQuick 2.7
Rectangle {
id: rectangle
color: "red"
width: 200
height: 200
visible: true
Text {
id:text
text: "It's working!"
}
}
I'm attempting to run the qml window on the right side of the screen, shown below.