Can't get going with QML, Python and QT Creator on Mac OS
-
I'm having a bear of a time getting going with Python QML development on Mac OS. So first I got everything working under Windows, figured out how to set up and point to the appropriately set up Python environment, and eventually I was able to just press the run button in Qt Creator and there it is, the QML hello world template for Python pops up a Window. Fantastic.
So now I go to Mac OS and do the exact same thing. When I press the run button, I get the red exclamation point and the message
"No device configuration set".
I have no idea what that means.
So I tried running from a Terminal window. There I get the message.
main.qml:1 module "QtQuick" version 2.13 is not installed
So I go to the Maintenance tool for Qt Creator and make sure to install that version of QtQuick for MacOS. But it makes no difference - I still get the error.
What do these two error messages mean?
-
Which version of PySide2 do you have ?
Which version of Qt Creator do you use ? -
Hi,
Can you explain how you setup your development environment on macOS ?
-
I set up a virtual environment using Anaconda, making sure that Pyside2 is installed correctly. I set the Python option in the preferences of QT Creator to point to that virtual environment. I created a new project from the Python QML "Qt for Python - QtQuick Application" template.
That's all I had to do on Windows, once I got the virtual environment set up properly. I was able to then press the run button and the app window popped up.
Not so on Mac OS. There is so much "under the hood" stuff for both QT and QT creator, I don't even know where to start understanding these error messages.
I did install QtQuick for Mac OS explicitly (I didn't have to do this for Windows), but it didn't help with the second error message.
-
@SGaist
I figured out what was causing the second problem. The version of QtQuick called out in the qml file was presumably newer than the version of QtQuick installed with Pyside 2. That's my guess. I don't know how I should have known this, the QML python tutorials and explanations are very short on "how this works". At any rate, changing the import statements to use an earlier version of QtQuick (2.0) solves the problem. And I still don't know how to know what version of QtQuick is installed with Pyside2.I still don't know why I can't run from within Qt Creator or what "No Device Configuration Set" means or how to fix it, or why it doesn't happen with the Windows version of QT creator. No amount of googling seems to help with this.
Very frustrating.
-
Which version of PySide2 do you have ?
Which version of Qt Creator do you use ? -
I found the problem. For some reason the default run configuration was set up for ARM on the Mac version. God knows why this was the default, it is a giant pothole for a newbie to fall into. Maybe it is because I have ARM dev tools on my machine for embedded work (which has no UI).
The clue was that the error about the device not being set up also showed a little alarm box in the corner that said "deploy". So I thought WTH am I trying to "deploy"? I opened up the Windows version of QT creator since it worked, and started comparing the build and run settings. It became apparent pretty quick what was wrong, and a few more minutes to convince QT Creator to change to a Desktop "Kit", at which point I could also set the Conda environment.
All's well that ends well. Now I just need to figure out the mental models to use for getting Python to interact with QML, including button handling, TextEdit update and validation, etc. Maybe there are examples for this, I can hope. So far the tutorials are thin.
-
AFAIK, you can reuse the same concepts that are used for C++ with some language adaptation.