import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
property int anum: 0
property int bnum: 1
onAnumChanged: {
bnum+=1
}
onBnumChanged: {
anum+=1
//Is there some way to stop loop call ?
//in widget we can unconnect some signal and slot
//but how to disconnect in qml
}
Button{
text:"begain"
onClicked: {
anum=anum+1
}
}
}
- when i push the button
- the 'anum' change to 1
- then the function onAnumChanged begain to execute
- then the bnum has been changed
- then the onBnumChanged begain to execute
- then the anum has been changed
- then loop from 3 to 7
is there some way to stop this?can i use some unbinding function to stop this like 'disconnect(sender,signal,receiver,slot)' in c++(widget)
Several things are needed to help break the binding loop:
We can borrow the userbreak pattern and implement here with mouse tapped, keypress and even visibility changing as things that will raise a userbreak.
You can Try it Online!