给我一个qPushbutton的样式表
时间: 2023-03-23 17:00:50 浏览: 97
以下是一个qPushButton的样式表:
```
QPushButton {
background-color: #4CAF50; /* 设置背景色为绿色 */
color: white; /* 设置文本颜色为白色 */
border-radius: 5px; /* 设置圆角半径为5px */
padding: 5px 10px; /* 设置内边距为5px和10px */
font-size: 16px; /* 设置字体大小为16px */
}
QPushButton:hover {
background-color: #3e8e41; /* 鼠标悬停时,背景色变为深绿色 */
}
QPushButton:pressed {
background-color: #e7e7e7; /* 按钮按下时,背景色变为灰色 */
color: black; /* 按钮按下时,文本颜色变为黑色 */
}
```
你可以将此样式表应用于你的QPushButton控件,例如:
```
QPushButton *myButton = new QPushButton("Click Me");
myButton->setStyleSheet("QPushButton { background-color: #4CAF50; color: white; border-radius: 5px; padding: 5px 10px; font-size: 16px; } QPushButton:hover { background-color: #3e8e41; } QPushButton:pressed { background-color: #e7e7e7; color: black; }");
```
这将创建一个带有绿色背景和白色文本的按钮,当鼠标悬停在按钮上时,背景色将变为深绿色,当按钮被按下时,背景色将变为灰色,文本颜色将变为黑色。
阅读全文
相关推荐


















