[PyQt] Sip and virtual functions

Phil Thompson phil at riverbankcomputing.com
Wed Jan 3 10:35:44 GMT 2018


On 3 Jan 2018, at 9:53 am, Guðjón Guðjónsson <gudjon.i.gudjonsson at gmail.com> wrote:
> 
> Hi list
> 
> I have been writing a new python wrapper for the Qwt library [1,2]
> And I still have problems with virtual function definitions.
> I got the advice to add the /Abstract/ keyword to the class definitions
> and this has led to the full wrapper compiling but running with the
> following error messages:
> 
> NotImplementedError: QwtPlotHistogram.dataSize() is abstract and must be overridden
> TypeError: Qwt.QwtPlotMultiBarChart represents a C++ abstract class and cannot be instantiated

Adding /Abstract/ was probably bad advice. It is only necessary if there are additional pure virtual functions that aren't mentioned in the .sip file.  Adding /Abstract/ to a class that has pure virtual functions in the .sip file shouldn't make any difference.

> I have also been playing with setting virtual functions = 0 or not. This led to a missing
> symbols error but with the /Abstract/ keyword in the right  place this error has disappeared.
> 
> There is a patch for the Qwt c++ library on Github that instantiates the pure virtual functions
> and by using that patch my python wrapper works perfectly but the wrapper must work
> without the patch.

Is the C++ QwtPlotHistogram class abstract? If not then there must be implementations of the pure virtual functions somewhere in the class hierarchy that are missing from your .sip files.

Phil


More information about the PyQt mailing list