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. Binding property to C++ function
Qt 6.11 is out! See what's new in the release blog

Binding property to C++ function

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.5k 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.
  • M Offline
    M Offline
    Merinas
    wrote on last edited by
    #1

    Hi,

    I've been working with qml plugin that have wrote myself. And I tried to bind some properties to some C++ function like that

    @MyNewItem{
    id:newItem
    }

    Item{
    property int test: newItem.somFuntion(someParam)
    }
    @

    The test property is binded to someParam. So if someParam change somFuntion will be recalled and test will be updated.
    Now what if something change internally which will lead to change the result of somFuntion ? My test property never knows about it. To make this work i need to add
    @onSomeSignal: newItem.somFuntion(someParam)@

    But thats lead to unhandy and disgracious code so I'm wandering if is there another way of linking the call of someFunction to a signal ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      Hi,

      There isn't currently a way to link them, but there is a suggestion for this in the bug tracker: "QTBUG-17323":http://bugreports.qt.nokia.com/browse/QTBUG-17323 . I'd suggest leaving a comment there with your usecase if possible -- it would be helpful to see more examples of where this plays out in real life (e.g. the kind of internal changes that cause this sort of situation).

      Thanks,
      Michael

      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