
qt的按钮怎么变颜色
1个回答
展开全部
首先要响应鼠标事件,然后通过 Style Sheets 改变按钮的外观
1. 从QPushButton派生一个自己的按钮类
2.在新类的构造函数中 调用 mouseTracking(true);以获取鼠标移动事件。
3. 重载 mouseMoveEvent(),在该函数中通过StyleSheet改变外观
如: setStyleSheet("background: yellow”);
Qt Style Sheets的使用请参考 Assistance中的内容 和 Style Sheet Example
1. 从QPushButton派生一个自己的按钮类
2.在新类的构造函数中 调用 mouseTracking(true);以获取鼠标移动事件。
3. 重载 mouseMoveEvent(),在该函数中通过StyleSheet改变外观
如: setStyleSheet("background: yellow”);
Qt Style Sheets的使用请参考 Assistance中的内容 和 Style Sheet Example
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询