YAML w=10=sh 绑定
QML property bind
当上下文变量改变时,isOn 属性是否也在下面的代码中被修改了?
property bool isOn: {
if(context === undefined)
return false;
return true
}
诀窍是,尝试一下:
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)
}
}
提示:是
当上下文变量改变时,isOn 属性是否也在下面的代码中被修改了?
property bool isOn: {
if(context === undefined)
return false;
return true
}
诀窍是,尝试一下:
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)
}
}
提示:是