passing python byte array to C++ function
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Greetings,
first of all I'd like to thank you for this great library, I find it really really useful.
My problem is that I'd like to pass an array of bytes (python array('B') type) from python
to a C++ function, but im not sure how to do that.
Could you please help me with this topic ?
Thank you in advance.
I think you need to use QByteArray in your C++ method to get access to the Python bytes.
Alternatively, if you don't want to make a copy of the Python bytes, you can use a pointer to PyObject in your signature, but then you would need to use the Python C-API to check if the passed object is PyBytes and to extract the data.
if i just use QByteArray, the interpreter gives the following error:
Last edit: Csaba Torda 2016-11-28
you need use a python string as the input parameter