QMLx学习06Button
- 1、Button
- 1.1 状态改变(checkable)
- 1.2 排斥性(autoExclusive)
- 1.3 重复触发(autoRepeat)、第一次触发延时时间(autoRepeatDelay)、相互之间触发的时间间隔(autoRepeatInterval)
- 1.4 鼠标按下(onDownChanged)
- 1.5 改变按钮背景颜色和边框颜色(background: Rectangle、border.color)
- 2、总结
1、Button
1.1 状态改变(checkable)
Button {id:btnwidth:50height:50checkable: falseonCheckableChanged: {console.log("changed",checkable)}onClicked: {btn.checkable = !btn.checkable }
1.2 排斥性(autoExclusive)
Button {id:btnwidth: 50height: 50autoExclusive: true checkable: true
}Button {id:btn1width: 50height: 50x:60autoExclusive: truecheckable: true
}Button {id:btn2width: 50height: 50x:120autoExclusive: truecheckable: true
}
1.3 重复触发(autoRepeat)、第一次触发延时时间(autoRepeatDelay)、相互之间触发的时间间隔(autoRepeatInterval)
Button{id:btnwidth: 50height: 50autoRepeat: true autoRepeatDelay: 2000 autoRepeatInterval: 1000 onClicked: {console.log("clicked")}onPressed: {console.log("pressed")}onReleased: {console.log("released");}
}
1.4 鼠标按下(onDownChanged)
Button{id:btnwidth: 50height: 50autoRepeat: true autoRepeatDelay: 2000 autoRepeatInterval: 1000 checkable: trueonDownChanged: {console.log("down:",down,"pressed",pressed) }}
1.5 改变按钮背景颜色和边框颜色(background: Rectangle、border.color)
Button{id:btnwidth: 50height: 50autoRepeat: truebackground: Rectangle{anchors.fill: btncolor: {if(btn.pressed){return "green"}else{return "blue"}}border.width: 5border.color: {if(btn.pressed){return "red"}else{return "black"}}}
}
2、总结
以上就是Button的一些基础知识了,浏览过程中,如若发现错误,欢迎大家指正,有问题的欢迎评论区留言或者私信。最后,如果大家觉得有所帮助,可以点一下赞,谢谢大家!祝大家天天开心,顺遂无虞! |
