Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-1661

Use PySide2 with Qt Design Studio

    XMLWordPrintable

Details

    • All

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

          }

      }

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thohartm Thomas Hartmann
            pratik.tayshete pratik.tayshete
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes