[PyQt] Method returning QList<const TYPE *>

Phil Thompson phil at riverbankcomputing.com
Sat Mar 26 18:53:21 GMT 2011


On Thu, 24 Mar 2011 16:51:45 +0100, Lorenzo Masini <rugginoso at develer.com>
wrote:
> Hi everyone,
> I'm using sip 4.10.5 and PyQt 4.7.4.
> If a method returns a QList of const pointers, it seems that the const
> keyword is discarded.
> Make gives me this error:
> --
> /usr/share/sip/PyQt4/QtCore/qlist.sip: In function ‘int
> convertTo_QList_0111Item(PyObject*, void**, int*, PyObject*)’:
> /usr/share/sip/PyQt4/QtCore/qlist.sip:195: error: cannot convert
> ‘QList<Item*>*’ to ‘QList<const Item*>*’ in assignment
> /usr/share/sip/PyQt4/QtCore/qlist.sip: In function ‘PyObject*
> convertFrom_QList_0111Item(void*, PyObject*)’:
> /usr/share/sip/PyQt4/QtCore/qlist.sip:138: error: invalid conversion
> from ‘const Item*’ to ‘Item*’
> --
> 
> Here's the sip file generating the error (it's almost identical to the
> header file):
> ---
> %Module Proof
> 
> %ModuleHeaderCode
> #include "proof.h"
> %End
> 
> %Import QtCore/QtCoremod.sip
> 
> class Item {
> %TypeHeaderCode
> #include "proof.h"
> %End
> 
> public:
>     Item(int i);
> };
> 
> class Proof {
> %TypeHeaderCode
> #include "proof.h"
> %End
> 
> public:
>     Proof();
>     ~Proof();
> 
>     QList<const Item *> items() const;
> };
> ---

Fixed in tonight's SIP and PyQt snapshots.

Phil


More information about the PyQt mailing list