Really struggling on how to write a constructor corresponding to std::shared_ptr. need some help on how to proceed

Suman Chatterjee sum_chat at
Tue May 18 07:22:18 BST 2021

 I am struggling to write the sip file for a header file which contains a constructor with a std::shared_ptr

Attachment(std::shared_ptr<QRTImpl::AttachmentImpl> impl, QObject* parent);

This is what I tried :

 Attachment(SIP_PYCALLABLE m_impl,QObject* parent = 0)[(std::shared_ptr<QRTImpl::AttachmentImpl>,QObject*)];

    // Make sure the callable doesn't get garbage collected, this is needed because refcount for a1 is 0
    // and the creation function pointer is passed to the metadata and it needs to be kept in memory.
    Py_INCREF( a0 );


    auto m_impl = [a0]() -> QRTImpl::AttachmentImpl *
      QRTImpl::AttachmentImpl  *result = nullptr;
      PyObject *s = sipCallMethod( NULL, a0, NULL );
      int state;
      int sipIsError = 0;
      result = reinterpret_cast<QRT_Impl::AttachmentImpl* >( sipForceConvertToType( s, sipTypeQRTImpl_AttachmentImpl, NULL, SIP_NOT_NONE, &state, &sipIsError ) );
      return result;

  sipCpp = new sipA_B_Attachment(m_impl,a1)



But I get the error

note: candidate constructor not viable: no known conversion from '(lambda at /Users/sum10122/pythonBindingsEnv/sip/sip/.../Data_Attachment.sip:50:19)' to 'std::shared_ptr<QRTImpl::AttachmentImpl>' for 1st argument

I will really appreciate if someone can help me on this

Thank You,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the PyQt mailing list