I am completely new to QML and PySide2. I am working on a desktop application where I want to make the UI using QML and connect it with PySide2. I saw some onlne documentation but was not able to find much about it. For an example, if I am creating a simple button using QML how can I access the button in PySide2.
Asked
Active
Viewed 91 times
0
-
No, you must not access QML elements from pyside2, what you must do is create a QObject that you export to QML and there make the connection, for example invoke a method of the QObject(@Slot) in onClicked and then implement the logic in that method. In duplicates there are examples of how to do it. Note: C++ concepts also apply to PySide2 (with some small limitations) – eyllanesc Feb 27 '20 at 05:25
-
Is there a simple example implementation of this process because I have never tried this method before. – Pratik Tayshete Feb 27 '20 at 05:44
-
1In my answers I always provide simple examples. Have you reviewed the answers to the duplicate questions? It seems that no, I recommend you check them as there are practical examples. On the other hand the source code of PySide2 provides many examples: you can download it from https://download.qt.io/official_releases/QtForPython/pyside2/ – eyllanesc Feb 27 '20 at 05:51