[PyQt] Passing numpy arrays into SIP bindings for C++/Qt code

Jeremy Sanders jeremy at jeremysanders.net
Wed Sep 16 08:11:19 BST 2015


John Wainwright GMail wrote:

> Hi all.  I’m very happily using PyQt for a large astrophotography project
> and have augmented it with a number of C++/Qt extensions using SIP.  I’d
> like to be able to pass numpy arrays into (and out of) the C++ extensions
> via SIP bindings and wondering if anyone as done this before or if there
> are any suggestions for best approaches.

I have some ugly code here which works by manually converting a numpy 
PY_OBJECT to a C++ wrapper numpy, but Phil's approach sounds far better.

https://github.com/jeremysanders/veusz/blob/master/veusz/helpers/src/qtloops/qtloops.sip

uses

https://github.com/jeremysanders/veusz/blob/master/veusz/helpers/src/qtloops/qtloops_helpers.h
and
https://github.com/jeremysanders/veusz/blob/master/veusz/helpers/src/qtloops/qtloops_helpers.cpp

Jeremy




More information about the PyQt mailing list