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. Fastest way to interact with QML
Qt 6.11 is out! See what's new in the release blog

Fastest way to interact with QML

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.2k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bricke
    wrote on last edited by
    #1

    Hi everyone, I'm having a question regarding interaction between C++ and QML.

    I've a set of button with different click behaviour (one is pulse, one have to switch state, one have to follow press-release action and so on...), and I'm thinking at the best way to set this particular behaviour.

    I know the behaviour on the C++ side of the object, so my question is related to the fasted way (or the best memory-side one) to send the behaviour to the qml-object from c++:

    1. Create a Q_INVOKABLE method that returns the behaviour and then check it everytime I need to do some action on the button (like on the onRelease function)

    2. Sends signal with the expected behaviour from C++ to QML and then elaborate it once received.

    I've to say that my button isn't on the first layer of my qml stack, they are on the second+ layer, so the signal have to pass thru one qml level before reach the elements.

    Any in-depth explanation on how this works?
    Thank you.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      You could make the behaviour a property on the c++ side, which uses a string. The string could then be used to call a method.
      @
      // qml
      Buttton {
      onPressed: root'handle_' + nativeObject.behaviour
      }
      @

      if behaviour would be 'flash' it would call root.handle_flash() JS function.

      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