Important: Please read the Qt Code of Conduct -

Binding property to C++ function

  • 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


    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 ?

  • Hi,

    There isn't currently a way to link them, but there is a suggestion for this in the bug tracker: "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).


Log in to reply