Qt js中binding的使用
1.一个组件的属性会自动进行绑定,单设置为静态值,这种绑定关系就会被删除,如下:
Rectangle {
width: 100
height: width * 2 //该属性会和宽度自定进行绑定
focus: true
Keys.onSpacePressed: {
height = width * 3 //一旦设置为静态值,绑定关系就会删除
}
}
2.js中使用binding
Rectangle {
width: 100
height: width * 2 //建立绑定关系
focus: true
Keys.onSpacePressed: {
height = Qt.binding(function() { return width * 3 }) //重新建立绑定关系
}
}
最后
以上就是火星上红牛最近收集整理的关于Qt js中binding的使用的全部内容,更多相关Qt内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复