Discussion:
[Development] Python Bindings
Luca Beldi
2018-11-23 08:22:50 UTC
Permalink
Hi Everyone,
I wanted to ask if I have to do anything to expose a new class added to Qt to "Qt for Python".
Do you have a manual or an example commit of what needs to be done to make it work?
Thanks in advance.

Luca Beldi
Cristián Maureira-Fredes
2018-11-23 14:52:28 UTC
Permalink
On 11/23/18 9:22 AM, Luca Beldi wrote:
> Hi Everyone,
>
> I wanted to ask if I have to do anything to expose a new class added to
> Qt to “Qt for Python”.
>
> Do you have a manual or an example commit of what needs to be done to
> make it work?
>
> Thanks in advance.
>
> Luca Beldi
>

Hello,

Regarding the process itself,
I recommend you to follow the implementation of another class
because we don't have any tutorial.

Overall the process should consist on:

- Add the new class into the module's typesystem
e.g.: pyside-setup/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml

- Add a couple of test cases:
e.g.: pyside-setup/sources/pyside2/tests/QtCore/
(don't forget to include the name of the scripts to the cmake file
on the same directory)

If you are lucky, the new class will require no extra steps,
but probably it will, so for this I recommend you to look
at a similar class so you can get an idea of how to solve the
issues you find. These issues could include:

- Ownership transfer
- Casting argument to different types
- Explicitly declare enums
- Adapt method signatures
- Include new signatures for a certain method
- etc

Join us on #qt-pyside if you have any further question.

Cheers


--
Dr. Cristian Maureira-Fredes
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin

Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
--
Edward Welbourne
2018-11-26 10:40:32 UTC
Permalink
On 11/23/18 9:22 AM, Luca Beldi wrote:
>> I wanted to ask if I have to do anything to expose a new class added to
>> Qt to “Qt for Python”.
>>
>> Do you have a manual or an example commit of what needs to be done to
>> make it work?

Cristián Maureira-Fredes (23 November 2018 15:52)
> Regarding the process itself,
> I recommend you to follow the implementation of another class
> because we don't have any tutorial.
>
> Overall the process should consist on:

I have turned those instructions into
https://wiki.qt.io/Adding_a_class_to_Qt_for_Python
so that you can supply them by reference in future; and so that folk can
improve them.

So at least we do now *kinda* have a tutorial ...

Eddy.
Venugopal Shivashankar
2018-11-27 06:45:57 UTC
Permalink
This blog post by Alexandru is a good starting point: http://blog.qt.io/blog/2018/05/31/write-python-bindings/



Venu



Sendt fra E-post<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10



________________________________
Fra: Development <development-***@lists.qt-project.org> på vegne av Edward Welbourne <***@qt.io>
Sendt: Monday, November 26, 2018 11:40:32 AM
Til: Cristián Maureira-Fredes
Kopi: ***@lists.qt-project.org
Emne: Re: [Development] Python Bindings

On 11/23/18 9:22 AM, Luca Beldi wrote:
>> I wanted to ask if I have to do anything to expose a new class added to
>> Qt to “Qt for Python”.
>>
>> Do you have a manual or an example commit of what needs to be done to
>> make it work?

Cristián Maureira-Fredes (23 November 2018 15:52)
> Regarding the process itself,
> I recommend you to follow the implementation of another class
> because we don't have any tutorial.
>
> Overall the process should consist on:

I have turned those instructions into
https://wiki.qt.io/Adding_a_class_to_Qt_for_Python
so that you can supply them by reference in future; and so that folk can
improve them.

So at least we do now *kinda* have a tutorial ...

Eddy.
Loading...