defining and calling QML functions directly from Python

Stefan Seefeld stefan at seefeld.name
Wed Sep 22 14:29:04 BST 2021


On 2021-09-22 8:59 a.m., Stefan de Konink wrote:
>> What is the right way to access and call a QML function from Python ? 
>
> I don't know if it it the 'right' way, but the documented way is no 
> introduce a Bridge object, which can exchange events from/to Qt.
>
> <https://doc.qt.io/qtforpython/tutorials/qmlintegration/qmlintegration.html> 
>
> <https://evileg.com/en/post/242/>


My goal is really to programmatically call a QML function / method, not 
bind it to a custom event. Let me provide a bit of context to clarify my 
goal:

I'm working with a C++ application (using Qt / QML), to which I have 
attached a Python interpreter, mainly for testing purposes. From that 
Python interpreter, I can access and interact with the application 
state. I would like to be able to include in these interactions the 
manipulation of the GUI, and I thought a good way to achieve this would 
be to call custom QML functions (or even existing slots such as 
`onClicked` slots of buttons).

I found some mention of similar techniques, such as in the thread 
started with 
https://www.riverbankcomputing.com/pipermail/pyqt/2014-February/033815.html, 
but couldn't get this working myself yet.

Thanks,

Stefan
-- 

       ...ich hab' noch einen Koffer in Berlin...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210922/af81f00a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .signature.png
Type: image/png
Size: 2754 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210922/af81f00a/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stefan.vcf
Type: text/x-vcard
Size: 4 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210922/af81f00a/attachment.vcf>


More information about the PyQt mailing list