[PyKDE] PyQt C API

Jim Bublitz jbublitz at nwinternet.com
Tue Oct 18 17:39:37 BST 2005


On Tuesday 18 October 2005 00:44, Toby Dickenson wrote:
> I am considering translating a few functions of our large PyQt application
> to C (or, probably, pyrex) as a performance optimisation, but I have
> stumbled at the first hurdle. How do you convert a PyObject pointer to a
> PyQt object into a pointer to the Qt C++ object?
>
> Thanks in advance,

Is this what you mean?

    PyObject *elem;   // Points to QRect object type
    QRect *cpp;
    int iserr = 0;

    cpp = (QRect *)sipForceConvertTo_QRect (elem, &iserr);
    if (iserr)
    {
        *sipIsErr = 1;
        return 0;
    }

The only thing that would change in most cases is substituting the particular 
Qt object type of interest for QRect everywhere. The "sipIsErr" is part of 
%MappedTypeCode - probably won't apply most places.


Jim




More information about the PyQt mailing list