Connecting signals from C++ application with Python?
-
wrote on 3 Oct 2023, 13:31 last edited by NoRulez 10 Mar 2023, 13:32
Hi everyone,
I have a C++ application which loads the *.ui files dynamically with the QUiLoader.
For this example MyWidget.uiNow I want to add the connections for QDial and a QLabel in the Python file (MyWidget.py).
What works in C++ currently is to get the QWidget* from the QUiLoader and access the items with findChildren<QLabel*>().
Can someone please help?
-
Hi everyone,
I have a C++ application which loads the *.ui files dynamically with the QUiLoader.
For this example MyWidget.uiNow I want to add the connections for QDial and a QLabel in the Python file (MyWidget.py).
What works in C++ currently is to get the QWidget* from the QUiLoader and access the items with findChildren<QLabel*>().
Can someone please help?
wrote on 3 Oct 2023, 14:36 last edited by JonB 10 Mar 2023, 14:36@NoRulez
Why aren't you using Qt + Python + PySide/PyQt for everything? I don't think it will be easy to connect across languages.You can try the
findChildren()
approach for Python, if that does whatever you want. -
Hi,
What exactly are you trying to do ?
Port your C++ code to Python ?
Use your C++ code in a Python application ? -
Hi,
What exactly are you trying to do ?
Port your C++ code to Python ?
Use your C++ code in a Python application ? -
@SGaist The main application is written in C++ and I want to extend it with python scripting
wrote on 4 Oct 2023, 08:30 last edited by@NoRulez
Here is my $0.02, unless/until someone else knows better.To add "Python scripting" to a C++ program you are best searching for C++ to Python scripting, not to do with Qt. That will be possible.
However, you (apparently) want to be able to handle Qt stuff like signals/slots from your Python "scripting". In order to call and deal with Qt stuff from Python you (normally) need a set of Python bindings/library, as provided by either PySide or PyQt. But these (again, normally) provide and require a full program written with them. I don't know how/whether they would allow you have Qt (with its event loop etc.) in a C++ program and somehow "connect" to that.
If that cannot be done could your "scripting" be done without any reference to anything Qt?
-
@NoRulez
Here is my $0.02, unless/until someone else knows better.To add "Python scripting" to a C++ program you are best searching for C++ to Python scripting, not to do with Qt. That will be possible.
However, you (apparently) want to be able to handle Qt stuff like signals/slots from your Python "scripting". In order to call and deal with Qt stuff from Python you (normally) need a set of Python bindings/library, as provided by either PySide or PyQt. But these (again, normally) provide and require a full program written with them. I don't know how/whether they would allow you have Qt (with its event loop etc.) in a C++ program and somehow "connect" to that.
If that cannot be done could your "scripting" be done without any reference to anything Qt?
Hi,
You might want to check the Scriptable Application example as a starting point.
-
Hi,
You might want to check the Scriptable Application example as a starting point.
1/7