Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
QDS 1.2.0
Description
I am trying to use the widgets made within Qt Design Studio inside PySide2. For eg, I made a simple button using Qt Design studio and I want to execute some function based on the clicked event triggered by the button. Is there a specific method by which we can use the UI generated in Qt Design Studio with PySide2.
Demo Project Structure in Qt DS:
Demo.qml
Demo.qmlproject
Demo.qmlproject.qtds
imports
qtquickcontrols2.conf
Screen01.ui.qml
PySide2 project structure:
Demo.qml
Demo.qmlproject
Demo.qmlproject.qtds
imports
qtquickcontrols2.conf
Screen01.ui.qml
main.py
main.py file:
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_()}}
Screen01.ui.qml file:
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")
}
}