[PyKDE] pointer to underlying C++ object?
phil at river-bank.demon.co.uk
Mon Sep 2 23:57:00 BST 2002
Mark Phillips wrote:
> Hi List,
> I'm new to PyQt (and to the list) and I'm having trouble figuring out
> how to do something.
> I want to write a PyQT application which calls a function that I
> have written in C++ and loaded into python via an extension module.
> The function (in C++) takes a pointer to a QImage object, as in:
> void foo(QImage *im)
> I've tried using swig to wrap this function and generate a python
> extension containing it. What I can't figure out is how to pass a C++
> QImage pointer to this function, when what I start with is QImage
> object created in python. I've tried something like
> import foo
> im = QImage()
> but that gives a runtime error which compains that foo is expecting a
> pointer argument. Apparently the python object 'im' dosn't directly
> correspond to the underlying C++ QImage object. That's not
> surprising, but can someone tell me how to access the underlying C++
> object? How can I create a QImage object in my python script, and
> then pass a pointer to the underlying C++ object to my function?
> I also tried using sip to wrap my function, with similar problems.
Using SIP to create the wrapper for foo() should allow you to do exactly
want to want. You shouldn't have got "similar problems".
More information about the PyQt