qml中,怎么给Rectangle设置鼠标移入变色,移除恢复?
Button怎么去掉边框? Button怎么改变背景色?
qml中,怎么给Rectangle设置鼠标移入变色,移除恢复?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- qtchen_1988 2019-07-24 15:02关注
import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Private 1.0 Rectangle { id:root width: 800 height: 480 color: "green" function mouseEnter(flag){ //处理鼠标进入或者移出变色 child.color = flag? "cyan":"darkGray" } Rectangle { id: child anchors.centerIn: parent width: 300 height: 200 color: "darkGray" MouseArea { id: mouseId anchors.fill: parent hoverEnabled: true onEntered: { //监听鼠标进入 mouseEnter(true); //console.log("#### Entered #####") } onExited: { //监听鼠标移出 mouseEnter(false); //console.log("#### Exited #####") } } } Button{ id: button width: 100 height: 30 x: child.x + child.width + 10 anchors.bottom: child.bottom style: ButtonStyle { background: Rectangle { border.color: "transparent"//去掉边框 color: control.pressed ? "#CD0000":"#CD00CD" //点击更改颜色 } } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 求解达问题(有红包)
- ¥15 请解包一个pak文件
- ¥15 不同系统编译兼容问题
- ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
- ¥30 数字电源对DSP芯片的具体要求
- ¥20 antv g6 折线边如何变为钝角
- ¥30 如何在Matlab或Python中 设置饼图的高度
- ¥15 nginx中的CORS策略应该如何配置
- ¥30 信号与系统实验:采样定理分析
- ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao