Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved PySide2 with Qt Design Studio

    Qt for Python
    4
    9
    2198
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pratik Tayshete last edited by

      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")
      }
      

      }

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by SGaist

        @Denni-0 Qt Design Studio has nothing to do with the old Designer application.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 3
        • P
          Pratik Tayshete last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • P
            Pratik Tayshete last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • P
              Pratik Tayshete last edited by

              Is it possible to use Material design components inside Qt Designer to create UI for a desktop application?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                @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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 5
                • B
                  BrookCronin last edited by

                  @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?

                  1 Reply Last reply Reply Quote 3
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    @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.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 4
                    • P
                      Pratik Tayshete last edited by

                      Thank you @SGaist and @Denni-0 for your advice. I really appreciate it. Can we include material design components for the widgets in PySide2?

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post