PySide2 with Qt Design Studio
-
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.qmlPySide2 project structure:
Demo.qml
Demo.qmlproject
Demo.qmlproject.qtds
imports
qtquickcontrols2.conf
Screen01.ui.qml
main.pymain.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.3Rectangle {
width: Constants.width
height: Constants.heightcolor: Constants.backgroundColor Button { id: nameButton x: 136 y: 227 text: qsTr("Button") }
}
-
@Denni-0 Qt Design Studio has nothing to do with the old Designer application.
-
I was just trying to create a UI (eg: button) in Qt Design Studio and was looking for a way to integrate the UI with PySide2. So should I make the UI in QML and then use it in PySide2 or is there a way to access the widgets made with Qt Design Studio in PySide2. I would really appreciate any suggestion as I am completely new to PySide2 and Qt.
-
Thanks a lot. Is there a way where we can create widgets or the UI in QtDS and use it in PySide2? I want to use Qt DS to design the UI for a desktop application.
-
Is it possible to use Material design components inside Qt Designer to create UI for a desktop application?
-
@Denni-0 said in PySide2 with Qt Design Studio:
Okay I am going to assume that you can export your GUI from QtDS much like you can from the Designer but then you will still need to run a conversion (which produces garbate code) that translates it into a version of python-qt that then gets rendered.
Still again creating something in straight PySide2 is fairly simple and easy so why do you need to complicate things and try to reinvent the wheel so-to-speak
Don't assume, these are unrelated technologies. QtDS creates QtQuick interfaces which has nothing to do with widgets.
-
@Denni-0 re - "or does it produce black-box untouchable code as well?" - It produces QML that you can edit as code if you prefer, or use the designer tooling if that's more your thing. Perhaps you should have checked this before writing your post?
-
@Denni-0 said in PySide2 with Qt Design Studio:
@BrookCronin said in PySide2 with Qt Design Studio:
@Denni-0 re - "or does it produce black-box untouchable code as well?" - It produces QML that you can edit as code if you prefer, or use the designer tooling if that's more your thing. Perhaps you should have checked this before writing your post?
Oooo aren't you the snarky one. Perhaps you should not have posted at all since your comment adds nothing to the original post just all negative criticism of someone who does answer questions. Heck if you actually knew more than I did you could have answered the OPs question but you did not. So all I can say is why don't you just crawl back under that useless rock you just poked your head out from under no one cares about this kind of junk.
Please stay polite.
It is a fact that every time the words Design/Designers appears in a Python related question, you first answer by saying that it is wrong to use that tool and that it generates crap code.
In the case of this thread, you did not even tried to check what exactly Qt Design Studio is and what it produces. You assumed something entirely wrong while at the same time criticizing what it produces without doing any verification.
Basically, in this thread, you are completely out of context and not helping the OP at all since he would like to run a QtQuick GUI with PySide2 and not one widget based.
Everybody can be wrong, so let's stay civilized and constructive.