python binding on Qt application
-
wrote on 9 Nov 2018, 15:29 last edited by sigmind 11 Sept 2018, 15:29
Hello! I am planning to extend my Qt C++ application capabilities with additional python modules. I have heard of Qt for Python for binding qt GUI within python. But is the vice versa is possible?
I mean, if I have a Qt C++ application, can I run python scripts within my C++ code? Is it possible ? -
-
wrote on 10 Nov 2018, 10:15 last edited by
Thanks. I'll check out
-
wrote on 10 Nov 2018, 19:05 last edited by
Check out PyBind11. I used to use Boost.Python for binding C++ code to expose it to Python, but Pybind11 is a lot more convenient to use and more modern.
-
wrote on 11 Nov 2018, 01:40 last edited by
+1 to pybind11, I started with it 2 weeks ago and I already have editor in qt & python coding environment & access between py-c++ stuff. Awesome So far!
One thing I wonder, does any1 know if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
-
+1 to pybind11, I started with it 2 weeks ago and I already have editor in qt & python coding environment & access between py-c++ stuff. Awesome So far!
One thing I wonder, does any1 know if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
@Dariusz said in python binding on Qt application:
if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
Can you please explain what you mean? Send what to where? You can use QVector in PySide.
-
@Dariusz said in python binding on Qt application:
if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
Can you please explain what you mean? Send what to where? You can use QVector in PySide.
wrote on 18 Nov 2018, 11:01 last edited by@jsulm said in python binding on Qt application:
@Dariusz said in python binding on Qt application:
if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
Can you please explain what you mean? Send what to where? You can use QVector in PySide.
well if we use QT in c++ project, and Pybind11 + python&pyside2, it means that we have QVector on C++ side and QVector on PySide2 as well. As pybind11 only accepts native structures as far as I'm aware, if I wish to send shared_ptr<QVector<classData>> to PySide2, can I just send it as QVector or do I need to always convert it to std::vector and then send that? - or return. Its about accessing c++ data from python.
-
@jsulm said in python binding on Qt application:
@Dariusz said in python binding on Qt application:
if we use PySide2 on python and Qt, can we directly send QVectors or we always have to convert them to std ones?
Can you please explain what you mean? Send what to where? You can use QVector in PySide.
well if we use QT in c++ project, and Pybind11 + python&pyside2, it means that we have QVector on C++ side and QVector on PySide2 as well. As pybind11 only accepts native structures as far as I'm aware, if I wish to send shared_ptr<QVector<classData>> to PySide2, can I just send it as QVector or do I need to always convert it to std::vector and then send that? - or return. Its about accessing c++ data from python.
@Dariusz Well, you need to send what pybind11 expects or can handle.
1/9