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 hotmail.com
Tue May 18 07:22:18 BST 2021


Hi,
 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*)];
     %MethodCode

    // 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 );

    Py_BEGIN_ALLOW_THREADS

    auto m_impl = [a0]() -> QRTImpl::AttachmentImpl *
    {
      QRTImpl::AttachmentImpl  *result = nullptr;
      SIP_BLOCK_THREADS
      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 ) );
      SIP_UNBLOCK_THREADS
      return result;
    };


  sipCpp = new sipA_B_Attachment(m_impl,a1)

    Py_END_ALLOW_THREADS

    %End


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,

Suman

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210518/e022a1cb/attachment.htm>


More information about the PyQt mailing list