[PyQt] Sip and pure virtual functions
Phil Thompson
phil at riverbankcomputing.com
Wed Jan 4 17:20:10 GMT 2017
On 4 Jan 2017, at 2:37 pm, Guðjón Guðjónsson <gudjon.i.gudjonsson at gmail.com> wrote:
>
> Hi Phil and Shaheed
>
> Thanks Shaheed. I tried with the Abstract keyword but I couldn't make it work
>
> On Wed, Jan 4, 2017 at 11:40 AM, Phil Thompson <phil at riverbankcomputing.com> wrote:
> On 4 Jan 2017, at 8:16 am, Guðjón Guðjónsson <gudjon.i.gudjonsson at gmail.com> wrote:
> >
> > Hi list
> >
> > I have been writing a python wrapper to the qwt6 library. It is new code, doesn't
> > build on PyQwt5.
> >
> > Qwt library:
> > http://qwt.sourceforge.net/
> >
> > My python wrapper:
> > https://github.com/GauiStori/PyQt-Qwt
> >
> > I do have a problem with pure virtual functions in Qwt.
>
> So what is the problem?
>
> If I don't use the patch, I get the following error:
>
> g++ -c -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Wall -W -DNDEBUG -I. -I/usr/include/x86_64-linux-gnu/qt5/ -I/usr/include/x86_64-linux-gnu/qt5/QtCore/ -I/usr/include/x86_64-linux-gnu/qt5/QtGui/ -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets/ -I/usr/include/qwt/ -I/usr/include/python3.5m -o sipQwtQwtSeriesStoreQwtSetSample.o sipQwtQwtSeriesStoreQwtSetSample.cpp
> ./sipQwtQwtSeriesStoreQwtSetSample.cpp: In function ‘void* array_QwtSeriesStoreQwtSetSample(Py_ssize_t)’:
> ./sipQwtQwtSeriesStoreQwtSetSample.cpp:372:52: error: invalid new-expression of abstract class type ‘QwtSeriesStore<QwtSetSample>’
> return new QwtSeriesStoreQwtSetSample[sipNrElem];
> ^
> In file included from qwt_series_store.sip:68:0:
> /usr/include/qwt/qwt_series_store.h:57:7: note: because the following virtual functions are pure within ‘QwtSeriesStore<QwtSetSample>’:
> class QwtSeriesStore: public virtual QwtAbstractSeriesStore
> ^~~~~~~~~~~~~~
> /usr/include/qwt/qwt_series_store.h:31:18: note: virtual void QwtAbstractSeriesStore::dataChanged()
> virtual void dataChanged() = 0;
> ^~~~~~~~~~~
> ./sipQwtQwtSeriesStoreQwtSetSample.cpp: In function ‘void* copy_QwtSeriesStoreQwtSetSample(const void*, Py_ssize_t)’:
> ./sipQwtQwtSeriesStoreQwtSetSample.cpp:379:114: error: invalid new-expression of abstract class type ‘QwtSeriesStore<QwtSetSample>’
> return new QwtSeriesStoreQwtSetSample(reinterpret_cast<const QwtSeriesStoreQwtSetSample *>(sipSrc)[sipSrcIdx]);
> ^
> Makefile:17: recipe for target 'sipQwtQwtSeriesStoreQwtSetSample.o' failed
> make: *** [sipQwtQwtSeriesStoreQwtSetSample.o] Error 1
>
> But if I use the patch everything works like charm. I would very much like not to add this patch to the Qwt library because
> I think there must be a way around it in Sip.
>
> The sip files, patch and .h files are attached.
...but not the version of qwt_series_store.sip that is causing the original problem.
You should use template classes rather than repeat the code in QwtSeriesStoreQwtIntervalSample, QwtSeriesStoreQPointF etc. See how ObjectDescriptionModel in PyQt4's phonon module is implemented.
I assume you are using the current version of SIP.
> > Another problem is getting the Qt include dir into the configure.py script.
> > I have to admit that I don't understand how it is done in the QScintilla script.
> > Can anyone point me to another example?
>
> Again, what is the problem?
>
> I cannot find out how to obtain the Qt include directory automatically in the configure.py script.
> For PyQt4 it is simple
>
> from PyQt4 import pyqtconfig
> pyqtconfig.Configuration().qt_lib_dir
>
> But I don't know how to do this for PyQt5.
So what's the problem with using QScintilla's configure.py as a basis?
Phil
More information about the PyQt
mailing list