[PyKDE] pointer to underlying C++ object?

Mark Phillips mbp at geomtech.com
Mon Sep 2 23:42:01 BST 2002


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()
    foo(im)

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.

Thanks in advance,

--Mark

Mark Phillips @ Geometry Technologies, LLC
P.O. Box 1170, Black Mountain, NC  28711
Phone: 828-664-1748
mbp at geomtech.com       http://www.geomtech.com




More information about the PyQt mailing list