[PyQt] unsupported function return type - provide %MethodCode and a C++ signature

Phil Thompson phil at riverbankcomputing.com
Sun Apr 26 16:37:40 BST 2015


On 26/04/2015 3:42 pm, Kevin Connor Arpe wrote:
> Hello,
> 
> This is my first post.
> 
> I forked the official QCustomPlot Git repo
> <https://gitorious.org/qcustomplot> to add Py3Qt5 bindings.  So far so
> good.  The basics work OK.
> 
> A few of the methods return (or receive) complex data structures of 
> either
> QMap or QHash.
> 
> One good example:
> typedef QMap<double, QCPBarData> QCPBarDataMap;
> QCPBarDataMap *QCPBars::data() const;
> void setData(QCPBarDataMap *QCPBars::data, bool copy=false);
> 
> Ref:
> https://github.com/kevinarpe/qcustomplot/blob/v1.3.1-Py3Qt5/src/plottables/plottable-bars.sip
> 
> If these two methods are enabled, I see a SIP error message as follows:
> unsupported function return type - provide %MethodCode and a C++ 
> signature
> unsupported argument return type - provide %MethodCode and a C++ 
> signature
> 
> On the surface, it makes sense, as these are quite complex data 
> structures
> as input/output.
> 
> I looked at the PyQt5 source file: sip/QtCore/qpycore_qmap.sip.  And 
> the
> official SIP docs here: %MappedType
> 
> I tried %Include QtCore/QtCoremod.sip, but no luck; same with %Include
> QtCore/qpycore_qmap.sip.
> 
> As I'm new to SIP, I'm unsure if I need %MappedType or %MethodCode in 
> this
> case.  I suppose %MappingType can be more generic, and %MethodCode 
> specific
> per ctor/method.
> 
> It is also possible that typedef is a problem.
> 
> What path do you advise to fix this issue with my SIP files?
> 
> (If there are old mailing list items about this, please kindly refer.  
> I
> couldn't find anything on Google.)

You need to implement QCPBarDataMap as a %MappedType. The obvious 
implementation is a Python dict with a float key and a value that is the 
Python wrapping of a QCPBarData.

Phil


More information about the PyQt mailing list