Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Run some python code from qml button onClicked?
QtWS25 Last Chance

Run some python code from qml button onClicked?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 578 Views
  • 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 Offline
    V Offline
    ViGor
    wrote on last edited by
    #1

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

    jsulmJ B 2 Replies Last reply
    0
    • V ViGor

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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      1
      • V ViGor

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

        B Offline
        B Offline
        Bob64
        wrote on last edited by
        #3

        @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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved