Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Set onClicked function based upon state

$
0
0
What I would like is that if the object is in a certain state it should call func1 when onClicked is called and in a different state should call a different function. So instead of something like this: Rectangle {   anchors.fill: parent   anchors.margins: 20     MouseArea {     id: area     anchors.fill: parent     onClicked:{    if state == "one":      ... do somethone for one...    else:      ... do somethone for two...         }   } } I want something like this. states [   State {     name = "one"  "somehow set area.onclicked to handleOne"   },   State {     name = "two"  "somehow set area.onclicked to handleTwo"   }, ]   function handleOne() { }   function handleTwo() { }   Rectangle {   anchors.fill: parent   anchors.margins: 20     MouseArea {     id: area     anchors.fill: parent   } }

Viewing all articles
Browse latest Browse all 18427

Trending Articles