Inconsistent output when running Qt Design Studio vs Python
-
Hello everyone, I've been trying to develop a Python Qt application with QML, so I learned about Qt Design Studio from the latest Qt Summit in Berlin and I thought why not try it and see if I'll get better workflow?
So basically I'm trying to use the drag and drop feature in Qt Design Studio to build the UI and write code for my data classes and my algorithms in Python but I can find inconsistent results when running the project using python vs running it in Qt Design Studio.So these are the steps I've done so far:
1- Create a Qt Design Studio application with a basic style.
2- Choose the export option "Enable Python Generator" which dumps a "Python" directory.
3- Installed Python, pyside6, and PySide6_DS libraries as guided here: https://doc.qt.io/qtdesignstudio/studio-designer-developer-workflow.html
4- Tried to run from Qt Design Studio and from using the python command "python main.py" as advised in the guide mentioned aboveUnfortunately, I get different styling when running using Python vs running using Qt Design Studio, can you please help with that issue? Am I doing something wrong?
As you'll notice the styling for the button is completely different.
Python Screenshot:
Qt Design Studio Screenshot:
-
@Amr-Essam said in Inconsistent output when running Qt Design Studio vs Python:
Am I doing something wrong?
No, your app is using different style when running compared to what Qt Design Studio is using. Normally you should not care as the style is selected depending on the platform when your app starts (to match the design of the platform).
-
I guess that the is that the Qt Quick style configuration file (qtquickcontrols2.conf) is not being applied in the case of the Python version.
You may add the file to the environment variables:# Assuming this is in <project>/Python/main.py, path to the DS project root folder project_root = Path(__file__).parent.parent os.environ["QT_QUICK_CONTROLS_CONF"] = str(project_root / "qtquickcontrols2.conf")
More info about the configuration file in the docs:
https://doc.qt.io/qt-6/qtquickcontrols-configuration.html -