问题
I am new to Qt Designer Studio. I just created a simple button in Qt Design Studio and I am trying to use the QML file with PySide2 but I am getting multiple import errors. Is there a specific way to implement Qt Design Studio qml files with PySide2.
The project name is Demo that I created in Qt Design Studio
The Demo Project structure:
Demo.qml
Demo.qmlproject
Demo.qmlproject.qtds
imports
qtquickcontrols2.conf
Screen01.ui.qml
The PySide2 project structure (main.py files includes the code):
Demo.qml
Demo.qmlproject
Demo.qmlproject.qtds
imports
qtquickcontrols2.conf
Screen01.ui.qml
main.py
main.py:
from PySide2.QtWidgets import QApplication, QMainWindow
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import QUrl
from imports import QtQuick
app = QApplication([])
view = QQuickView()
url = QUrl("Screen01.ui.qml")
view.engine().addImportPath("imports")
view.setSource(url)
view.show()
app.exec_()
Error:
module "QtStudio3D" is not installed
module "Qt.SafeRenderer" is not installed
Screen01.ui.qml
import QtQuick 2.12
import Demo 1.0
import QtQuick.Controls 2.3
Rectangle {
width: Constants.width
height: Constants.height
color: Constants.backgroundColor
Button {
id: nameButton
x: 136
y: 227
text: qsTr("Button")
}
}
来源:https://stackoverflow.com/questions/60237780/use-qt-design-studio-qml-with-pyside2