Sip and virtual functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sip and virtual functions

Guðjón Guðjónsson
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

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.


Regards
Gudjon
Ps. I got the advice earlier to use template functions in the sip files.
I would very much prefer to get the wrapper working without any patches to Qwt
first and then change to template classes and functions.

[1] Qwt library:
http://qwt.sourceforge.net/

[2] My python wrapper:
https://github.com/GauiStori/PyQt-Qwt

[3] https://riverbankcomputing.com/pipermail/pyqt/2017-January/038480.html


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Sip and virtual functions

Phil Thompson-5
On 3 Jan 2018, at 9:53 am, Guðjón Guðjónsson <[hidden email]> 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
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Sip and virtual functions

Guðjón Guðjónsson
Hi list

I think I have found a solution to my problem. Not the most beautiful one but it may lead to one.

I don't need to patch the Qwt header files for compiling Qwt, only the python wrapper.
This solves all my problems. I am sure this can be implemented in the .sip files but that is a
fairly minor issue.

Thanks for the help I have got.

Regards
Gudjon


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt