Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Design Studio for python
Forum Updated to NodeBB v4.3 + New Features

Qt Design Studio for python

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 833 Views 1 Watching
  • 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.
  • G Offline
    G Offline
    Guilherme Franklin
    wrote on 4 Aug 2023, 19:26 last edited by
    #1

    I'm having trouble creating a designer in Qt Design Studio and exporting it as python code.

    If anyone can help me with this, or know of a course that teaches python programming using Qt Design Studio, I would be very grateful.

    J 1 Reply Last reply 4 Aug 2023, 19:43
    0
    • G Guilherme Franklin
      4 Aug 2023, 19:26

      I'm having trouble creating a designer in Qt Design Studio and exporting it as python code.

      If anyone can help me with this, or know of a course that teaches python programming using Qt Design Studio, I would be very grateful.

      J Offline
      J Offline
      JonB
      wrote on 4 Aug 2023, 19:43 last edited by
      #2

      @Guilherme-Franklin
      Hi. Are you sure you mean Qt Design Studio, not Designer? Design Studio is for designing the look of a UI, not for writing code.

      G 1 Reply Last reply 10 Aug 2023, 14:39
      0
      • J JonB
        4 Aug 2023, 19:43

        @Guilherme-Franklin
        Hi. Are you sure you mean Qt Design Studio, not Designer? Design Studio is for designing the look of a UI, not for writing code.

        G Offline
        G Offline
        Guilherme Franklin
        wrote on 10 Aug 2023, 14:39 last edited by
        #3

        @JonB

        Yes. I'm new to Qt and don't know much about the features.

        I managed to understand that Qt Design Studio is for creating the user interface, but I am not able to import it into a python code to be able to implement the features of my program.

        For example.

        I have the following python code:

        # This Python file uses the following encoding: utf-8
        import sys
        from pathlib import Path
        
        from PySide6.QtGui import QGuiApplication
        from PySide6.QtQml import QQmlApplicationEngine
        
        
        if __name__ == "__main__":
             app = QGuiApplication(sys.argv)
             engine = QQmlApplicationEngine()
             qml_file = Path(__file__).resolve().parent / "main.qml"
             engine.load(qml_file)
             if not engine.rootObjects():
                 sys.exit(-1)
             sys.exit(app.exec())
        

        It imports a .qml file:

        import QtQuick
        import QtQuick.Window
        
        Window {
             width: 640
             height: 480
             visible: true
             title: qsTr("Hello World")
        }
        

        This way works correctly, however, when I create a new project in Qt Design Studio, I have the following problem:

        ed154247-f112-4519-bb8e-ab3b831e02c2-image.png

        In this structure I include a python file with the same previous code inside the content folder and import the App.qml file

        # This Python file uses the following encoding: utf-8
        import sys
        from pathlib import Path
        
        from PySide6.QtGui import QGuiApplication
        from PySide6.QtQml import QQmlApplicationEngine
        
        
        if __name__ == "__main__":
             app = QGuiApplication(sys.argv)
             engine = QQmlApplicationEngine()
             qml_file = Path(__file__).resolve().parent / "App.qml"
             engine.load(qml_file)
             if not engine.rootObjects():
                 sys.exit(-1)
             sys.exit(app.exec())
        

        f5545ad9-c43c-46df-8324-a13dbae920cb-image.png

        But when I run the python code I get the following error:

        QQmlApplicationEngine failed to load component
        file:///C:/Users/guirn/Documents/UntitledProject/content/App.qml:5:1: module "UntitledProject" is not installed

        I want to be able to solve this problem so I can run my interface created in Qt Design Studio with Python.

        A 1 Reply Last reply 10 Aug 2023, 16:08
        0
        • G Guilherme Franklin
          10 Aug 2023, 14:39

          @JonB

          Yes. I'm new to Qt and don't know much about the features.

          I managed to understand that Qt Design Studio is for creating the user interface, but I am not able to import it into a python code to be able to implement the features of my program.

          For example.

          I have the following python code:

          # This Python file uses the following encoding: utf-8
          import sys
          from pathlib import Path
          
          from PySide6.QtGui import QGuiApplication
          from PySide6.QtQml import QQmlApplicationEngine
          
          
          if __name__ == "__main__":
               app = QGuiApplication(sys.argv)
               engine = QQmlApplicationEngine()
               qml_file = Path(__file__).resolve().parent / "main.qml"
               engine.load(qml_file)
               if not engine.rootObjects():
                   sys.exit(-1)
               sys.exit(app.exec())
          

          It imports a .qml file:

          import QtQuick
          import QtQuick.Window
          
          Window {
               width: 640
               height: 480
               visible: true
               title: qsTr("Hello World")
          }
          

          This way works correctly, however, when I create a new project in Qt Design Studio, I have the following problem:

          ed154247-f112-4519-bb8e-ab3b831e02c2-image.png

          In this structure I include a python file with the same previous code inside the content folder and import the App.qml file

          # This Python file uses the following encoding: utf-8
          import sys
          from pathlib import Path
          
          from PySide6.QtGui import QGuiApplication
          from PySide6.QtQml import QQmlApplicationEngine
          
          
          if __name__ == "__main__":
               app = QGuiApplication(sys.argv)
               engine = QQmlApplicationEngine()
               qml_file = Path(__file__).resolve().parent / "App.qml"
               engine.load(qml_file)
               if not engine.rootObjects():
                   sys.exit(-1)
               sys.exit(app.exec())
          

          f5545ad9-c43c-46df-8324-a13dbae920cb-image.png

          But when I run the python code I get the following error:

          QQmlApplicationEngine failed to load component
          file:///C:/Users/guirn/Documents/UntitledProject/content/App.qml:5:1: module "UntitledProject" is not installed

          I want to be able to solve this problem so I can run my interface created in Qt Design Studio with Python.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on 10 Aug 2023, 16:08 last edited by
          #4

          @Guilherme-Franklin I would strongly discourage you from using Python when your application is "GUI oriented". From my recent experience - Python is "(simple / single) command line scripting language" and adding GUI to it is not a simple task. You can use QDesigner to build the GUI ( ui file ) then you need "uic" ( user interface compiler) to "convert" .ui to . py and that is where the tools do not work well together.
          But that is my (fact based) opinion, your mileage will vary...

          G 1 Reply Last reply 10 Aug 2023, 17:55
          0
          • A Anonymous_Banned275
            10 Aug 2023, 16:08

            @Guilherme-Franklin I would strongly discourage you from using Python when your application is "GUI oriented". From my recent experience - Python is "(simple / single) command line scripting language" and adding GUI to it is not a simple task. You can use QDesigner to build the GUI ( ui file ) then you need "uic" ( user interface compiler) to "convert" .ui to . py and that is where the tools do not work well together.
            But that is my (fact based) opinion, your mileage will vary...

            G Offline
            G Offline
            Guilherme Franklin
            wrote on 10 Aug 2023, 17:55 last edited by
            #5

            @AnneRanch

            I understand your position, however, this problem I'm having is recurrent even in other languages.

            For example, I created a mobile project in Qt Design Studio with the following structure:

            b9d2448a-2093-43cb-be32-856bbf8440f8-image.png

            Then I opened it in Qt Creator to be able to compile it into an android apk and I'm having the following problem:

            488787cd-3621-4bfa-bb91-b02fdf1a492a-image.png

            That is, even if I follow your advice of not using python, I will still have the same problem. I would like to ask for your help in resolving the issue.

            1 Reply Last reply
            0

            1/5

            4 Aug 2023, 19:26

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved