如何改变QPushButton的焦点颜色(高亮颜色)

问题描述 投票:0回答:1

如何更改按钮的焦点颜色,如下所示:

我还更改了按钮的背景颜色和调色板,但仍然没有发生任何变化。

qt qt5 qtstylesheets qpushbutton qpalette
1个回答
2
投票

使用样式表:

QPushButton:focus:pressed{ background-color: some_colour; }
QPushButton:focus{ background-color: some_other_colour; }

您可以使用 Qt Creator 将样式添加到按钮,或者通过在按钮上调用

setStyleSheet("...")
将它们加载到代码中。

© www.soinside.com 2019 - 2024. All rights reserved.