[PyQt] SIP multiple inheritance with template base class

Phil Thompson phil at riverbankcomputing.com
Sat Mar 31 11:57:30 BST 2018


On 30 Mar 2018, at 1:53 pm, Giuseppe Corbelli <corbelligiuseppe at mesdan.it> wrote:
> 
> Hi all
> for an ongoing project I am developing a Python interface for QCustomPlot.
> You can find it at https://github.com/cowo78/QCustomPlot-PyQt5/tree/v2.0.0
> 
> My first attempt with sip so look out for stupid mistakes.
> 
> SIP 4.19.8, (Py)Qt 5.9.2 on linux/gcc 7.3
> 
> I have the following hierarchy:
> 
> template <DataType>
> class QCPAbstractPlottable1D : public QCPAbstractPlottable, public QCPPlottableInterface1D /Abstract/
> {
> %TypeHeaderCode
> #include <QCustomPlot/src/qcp.h>
> #include "helper.h"
> %End
> { ... }
> 
> typedef QCPAbstractPlottable1D<QCPBarsData> QCPAbstractPlottable1D_QCPBarsData;
> 
> class QCPBars : public QCPAbstractPlottable1D_QCPBarsData
> {
> %TypeHeaderCode
> #include <QCustomPlot/src/qcp.h>
> 
> typedef QCPAbstractPlottable1D<QCPBarsData> QCPAbstractPlottable1D_QCPBarsData;
> %End
> ...
> }
> 
> Nevermind the helper.h include for a second. With this code the c++ generated for the QCPAbstractPlottable1D_QCPBarsData lacks a typedef.
> 
> The typedef'ed template specialization produces sipQCustomPlotQCPAbstractPlottable1D_QCPBarsData.cpp which references the typedef itself (QCPAbstractPlottable1D_QCPBarsData) but it is not copied in the generated file. The helper.h just works around the issue by providing the relevant typedef.
> 
> The full 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.
> 
> Something wrong in my approach or an obscure bug somewhere?

I'm not sure what the issue is that you are raising. Is it the fact that you have to provide the C++ typedef (and, if you do, it works Ok)? If you specify something in the .sip file it is assumed that this reflects something that is in the C++ code - and you need to provide it if it doesn't.

Phil


More information about the PyQt mailing list