How to give a JavaScript function to a qml component [solved]

  • Hi,
    I did a QML component that use a function f(x). It works fine but i would like to give any function to this component as a property ( or another way if this one doesn't work ).
    Is there a way to do this and to be able to put several components with différents function on a screen.

  • It's not clear what you want to achieve.
    Can you give us an example of your objective ?

  • Hi,
    i found it. If my component use f(x) and this component is in a file Draw.qml

    Simply do it
    Draw {
    function f(x) {
    return Math.cos(x)

    Have a nice day

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.