SIP - set slots directly?
Scott Talbert
swt at techie.net
Fri Jan 24 13:33:13 GMT 2025
On Fri, 24 Jan 2025, Phil Thompson wrote:
> On 23/01/2025 15:41, Scott Talbert wrote:
>> Is there a way to set a slot's function directly with SIP?
>>
>> For example, if I wanted to just set an iterator object type's tp_iter
>> slot to PyObject_SelfIter?
>>
>> Thanks,
>> Scott
>
> Defining a method called __iter__() with the correct signature should do it.
> It will set the slot to a SIP generated function that will call your
> implementation.
>
> See https://python-sip.readthedocs.io/en/stable/specification_files.html
Yes, this is what I ended up doing:
PyObject* __iter__();
%MethodCode
return PyObject_SelfIter(sipSelf);
%End
It looks a bit weird in the generated code (with the multiple unused
returns), but it seems to work.
Thanks,
Scott
More information about the PyQt
mailing list