If the enabled
property binding doesn't work, you can always prevent your function from getting called yourself:
Button {
onClicked: {
if (this.enabled) { // Don't allow multiple clicks
console.log('clicked')
this.enabled = false
do_something()
this.enabled = true
}
}
}
UPDATE:
In response to your own answer to your question, I'd suggest an alternative to a timer is Qt.callLater()
. It will essentially post an event on the event queue rather than call the function directly. That allows just enough time for other processing to occur.
Button {
id: btn
onClicked: {
console.log('clicked')
this.enabled = false
Qt.callLater(callback);
}
function callback() {
do_something()
btn.enabled = true
}
}
But I'm still wondering if you ever tried my original answer, because I think it's much easier, and it should work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…