Qt Design Studio for python
-
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.
-
@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. -
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:
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())
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 installedI want to be able to solve this problem so I can run my interface created in Qt Design Studio with Python.
-
@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... -
@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:
Then I opened it in Qt Creator to be able to compile it into an android apk and I'm having the following problem:
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.