Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Run some python code from qml button onClicked?

    QML and Qt Quick
    3
    3
    272
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • V
      ViGor last edited by

      Brand new to qml, but is there an example of running some python code when a QML button onClicked?
      Thanks in advance

      jsulm B 2 Replies Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @ViGor last edited by

        @ViGor You can't run Python code directly in QML. You will either need to run Python script as external proccess from C++ or embed Python interpreter in your app (also requires C++).

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • B
          Bob64 @ViGor last edited by

          @ViGor I don't know if this will fit your requirements but it might be worth looking at PySide, which is a Python-based exposure of Qt. It would probably mean writing your application in Python but I believe that this approach would provide a mechanism for calling from QML to Python, by exposing a slot from Python in the same way that in a C++-based QML project one can interact with slots in the C++ back end. I have no experience of PySide but thought it was worth mentioning in case it might work for you.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post