[PyQt] SIP default constructor issue

Kelvin Rodriguez kr788 at nau.edu
Sat Feb 4 20:20:08 GMT 2017


Hi Phil,

Default constructor isn’t auto generated by the compiler because there
already exists a parameterized constructor in the class (just not a default
constructor). I am not exposing that parameterized constructor via SIP
because I only want to get at BundleImage's attributes (hence why its not
in the SIP file). Instances are generated elsewhere in another C++ class.
That other class creates instances which is stored as a member variable
which we want to access via Python. For our use case we don’t want to
create instances directly in Python.

On Sat, Feb 4, 2017 at 3:14 AM, Phil Thompson <phil at riverbankcomputing.com>
wrote:

> On 4 Feb 2017, at 1:31 am, Kelvin Rodriguez <kr788 at nau.edu> wrote:
> >
> > Hi all,
> >
> >
> >
> > I am trying to wrap fairly large C++ api using SIP. In trying to build
> the module, I get the error:
> >
> >
> >
> > ./sipbundleIsisBundleImage.cpp: In function ‘void*
> array_Isis_BundleImage(Py_ssize_t)’:
> >
> > ./sipbundleIsisBundleImage.cpp:86:43: error: no matching function for
> call to ‘Isis::BundleImage::BundleImage()’
> >
> >     return new Isis::BundleImage[sipNrElem];
> >
> >
> >
> > We do not user the default contractor in our codebase, so one does exist
> for the class BundleImage. It seems like SIP requires there to exist a
> default constructor for the wrapped class? This can be fixed easily by
> adding a default contractor to the C++ class being wrapped, but I would
> like to avoid it if possible.
> >
> >
> >
> > My questions are: Does SIP allow for a clean way to eliminate this error
> without changing the codebase being wrapped? Does SIP actually require a
> default constructor or is there something I am doing wrong?
> >
> >
> >
> > The .sip for bundle Image is as barebones as the class:
> >
> >
> >
> > namespace Isis {
> >
> >  class BundleImage {
> >
> >  %TypeHeaderCode
> >
> >    #include "BundleImage.h"
> >
> >  %End
> >
> >
> >
> >  public:
> >
> >
> >
> >    QString serialNumber();
> >
> >    QString fileName();
> >
> >  };
> >
> > };
>
> C++ will generate a default ctor in the above case which SIP will create a
> wrapper for. If the above fails then it suggests your C++ is actually
> disabling the default ctor - so you should reflect that in the .sip file.
>
> Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170204/4f052c7d/attachment.html>


More information about the PyQt mailing list