gpt4 book ai didi

c++ - 表单上的按钮样式

转载 作者:行者123 更新时间:2023-12-04 07:21:26 26 4
gpt4 key购买 nike

请告诉我如何正确指定当您将鼠标悬停在这些按钮上时表单上的所有按钮都具有样式这一事实的参数?除了按钮的样式,表单本身也有样式。
我在构造函数中指定它:

{
ui->setupUi(this);
this->setStyleSheet("background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan;"
"QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");

}
如果我只为按钮指定一个单独的样式,它会起作用,但我需要将所有样式组合到一个条目中。
this->setStyleSheet("QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");

最佳答案

我想你正在寻找这个

this->setStyleSheet("QWidget { background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan; }"
" QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");
如果您的主表单是 QMainWindow您也可以只为 QMainWindow 设置样式但并非适用于所有人 QWidget
this->setStyleSheet("QMainWindow { background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan; }"
" QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");

关于c++ - 表单上的按钮样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68471860/

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