gpt4 book ai didi

css - 如何设置 QPushButton 选中状态的样式以移除灰点?

转载 作者:可可西里 更新时间:2023-11-01 13:01:01 25 4
gpt4 key购买 nike

我正在使用 Qt 5.3.0。当我在 QPushButton 的选中状态上应用一些背景颜色时,按钮将在选中时填充灰色点(在我想要的背景颜色之上)。

这是一个小测试程序(使用 qtcreator 但也可以通过编码完成):1、创建一个qt应用2、拖入一个QPushButton,设置为flat and checkable3、在w.show()之前添加这几行

w.setStyleSheet("\
QPushButton { \
color:white; \
} \
QPushButton:checked{\
background-color: rgb(80, 80, 80);\
}\
QPushButton:hover{ \
background-color: grey; \
border-style: outset; \
} \
");

4、运行app并勾选按钮

您会看到按钮变为虚线,但我需要选中的按钮为纯色,如 rgb(80, 80, 80)。我错过了什么吗?

最佳答案

我只需在样式表的 QPushButton:checked 属性上设置 border: none; 即可删除这些点。

在你的例子中,它应该是这样的:

w.setStyleSheet("\
QPushButton { \
color:white; \
} \
QPushButton:checked{\
background-color: rgb(80, 80, 80);\
border: none; \
}\
QPushButton:hover{ \
background-color: grey; \
border-style: outset; \
} \
");

在这里您可以看到选中按钮时的结果:

enter image description here

关于css - 如何设置 QPushButton 选中状态的样式以移除灰点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24718722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com