[PyQt] SIP multiple inheritance with template base class

Phil Thompson phil at riverbankcomputing.com
Thu Apr 5 17:23:51 BST 2018


On 5 Apr 2018, at 11:27 am, Giuseppe Corbelli <corbelligiuseppe at mesdan.it> wrote:
> 
> On 04/03/2018 04:35 PM, Phil Thompson wrote:
>> Sorry, still not clear. When you "provide the typedefs" do you mean in the .sip file or as a C++ typedef (possibly as handwritten code in the .sip file)?
> 
> In the .sip file, see below how to reproduce.
> Let's say I will not pursue a career in teaching since it seems my explanations are not the best you can find around.
> 
>>> The generated code for the explicit template specialization does not include the relevant typedef.
>>> This is the compiler error:
>>> 
>>> sipQCustomPlotQCPAbstractPlottable1D_QCPBarsData.cpp:121:18: error: ‘QCPAbstractPlottable1D_QCPBarsData’ in namespace ‘::’ does not name a type
>>>         const  ::QCPAbstractPlottable1D_QCPBarsData *sipCpp;
>>> 
>>> Again, the error can be reproduced by checking out branch  v2.0.0 of https://github.com/cowo78/QCustomPlot-PyQt5.git and commenting out the #include "helper.h" directive in plottable1d.sip.
>> Please provide a short, complete example that demonstrates the problem.
> 
> git clone https://github.com/cowo78/QCustomPlot-PyQt5
> cd QCustomPlot-PyQt5/
> git checkout v2.0.0
> git submodule update --init QCustomPlot
> echo "" > helper.h
> python3 setup.py build

Not exactly what I had in mind as a short, complete example...

> Compilation will fail because of a missing typedef.
> The relevant pieces are:
> * template class QCPAbstractPlottable1D in plottable1d.sip
> * typedef QCPAbstractPlottable1D<QCPBarsData> in plottable-bars.sip

It fails before that...

In file included from build/temp.macosx-10.9-x86_64-3.7/sipQCustomPlotcmodule.cpp:15:
build/temp.macosx-10.9-x86_64-3.7/sipAPIQCustomPlot.h:20:10: fatal error:
      'QMetaType' file not found
#include <QMetaType>

However, you have specified the typedef in the %TypeHeaderCode in plottable-bars.sip. If you want the typedef to be visible to the rest of the generated code then put it in %ModuleHeaderCode instead.

Phil


More information about the PyQt mailing list