Managing Qt event loop in a Python binding created from C++ library
-
I have a C++ library that depends on Qt5 and uses signal/slots internally (mainly for communicating between threads and for QTimers). The library is currently being used for qt GUI application and everything works fine.
I want to expose some of the API to Python so that the library could be used as a regular python module in a standalone Python script. I created the bindings using pyside11 and I'm able to call the C++ function from Python as expected.
However none of the signal/slots used internally works as there is no QCoreApplication instance and no event loop in the Python. I tried exposing an instance of QCoreApplication and the QCoreApplication::exec function (using pybind11) however as exec() function will block the execution, I can't use it in Python.
Is there a workaround so that I can still use my library as a regular Python module and the internal signal/slots runs normally.
I would prefer something that doesn't involve adding PySide2 dependency to the Python side especially as the scripts won't any Qt specific functions.