使用悬停和按下样式表 Qt [英] Using Hover and Pressed stylesheet Qt

查看:37
本文介绍了使用悬停和按下样式表 Qt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在按钮 pushButton 样式表中使用了它

I used this in my button pushButton stylesheet

 QPushButton#pushButton {
     background-color: yellow;
 }
 QPushButton#pushButton:pressed {
     background-color: rgb(224, 0, 0);     
 }
 QPushButton#pushButton:hover {
     background-color: rgb(224, 255, 0);
 }

当我将鼠标悬停在它上面时,它会改变颜色,就像我期望的那样,但是即使我按下按钮,悬停颜色仍然存在.我尝试更改顺序,但仍然是同样的问题.Qt 中的小新.

when I hover my mouse over it, it changes color, like I expect it to , But the hover color remains even when I press the button. I tried changing the order, but its still the same problem . little new in Qt.

推荐答案

可以组合状态,例如:

QPushButton:hover:!pressed
{
  border: 1px solid red;
}

QSS 参考 - 状态

这篇关于使用悬停和按下样式表 Qt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆