How add python class to C++ project?
-
I used:
/usr/lib/qt6/rcc src/resources.qrc -o src/resources.py
But you need to specify
-g python
too.Using pyotherside you can use python in QML with C++.
-
Hi,
What do you want to do with Python ?
-
@SGaist Hi,
I am thinking about adding some backend.To save/edit/import etc. configuration.
-
@realroot
So far as I know mixing Python with C++ is (relatively) not so straightforward. If you want to use Python and haven't written any C++ have you considered just using Python with QML, no C++?@JonB
Yes I thought about that.
Do I make a app.pyproject?
I tried that but Qt Creator didn't show any files besides app.pyproject.
Maybe I missed something.If I use C++ it will be easier to make a binary with all files embedded I think.
And I can keep the current state.For example this app https://gitlab.com/mx-moment/moment has a main.cpp and uses mostly python.
Not sure how. -
@JonB
Yes I thought about that.
Do I make a app.pyproject?
I tried that but Qt Creator didn't show any files besides app.pyproject.
Maybe I missed something.If I use C++ it will be easier to make a binary with all files embedded I think.
And I can keep the current state.For example this app https://gitlab.com/mx-moment/moment has a main.cpp and uses mostly python.
Not sure how.I made the project use python instead of C++.
I converted resource.qrc to resource.py but I have error when I run the app:
Starting /path/app/venv/bin/python -u main.py... Traceback (most recent call last): File "/path/app/src/main.py", line 8, in <module> import resources File "/path/app/src/resources.py", line 121514 QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) ^ SyntaxError: unmatched ')'
The file resource.py shows the local path but it should be upload with the app code and that does not seem correct.
-
I made the project use python instead of C++.
I converted resource.qrc to resource.py but I have error when I run the app:
Starting /path/app/venv/bin/python -u main.py... Traceback (most recent call last): File "/path/app/src/main.py", line 8, in <module> import resources File "/path/app/src/resources.py", line 121514 QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) ^ SyntaxError: unmatched ')'
The file resource.py shows the local path but it should be upload with the app code and that does not seem correct.
-
I used:
/usr/lib/qt6/rcc src/resources.qrc -o src/resources.py
But you need to specify
-g python
too.Using pyotherside you can use python in QML with C++.
-