当上下文变量发生变化时,isOn属性是否也在下面的代码中进行了修改?
property bool isOn: {
if(context === undefined)
return false;
return true
}
答案 0 :(得分:3)
诀窍是,尝试一下:
import QtQuick 2.7
import QtQuick.Controls 2.0
ApplicationWindow {
id: appWindow
width: 500
height: 800
visible: true
property bool isOn: {
if(context === undefined)
return false;
return true
}
property var context
Button {
text: isOn
onClicked: (context ? context = undefined : context = 1)
}
}
提示:是