qpushbutton qss
时间: 2023-09-14 11:12:05 浏览: 121
QPushButton is a widget in Qt that allows users to trigger certain actions or events when clicked. QSS (Qt Style Sheets) is a powerful tool used in Qt to customize the look and feel of user interfaces.
To apply QSS to a QPushButton, you can use the setStyleSheet() function. Here's an example:
```
QPushButton {
background-color: blue;
color: white;
border: 2px solid black;
border-radius: 5px;
padding: 5px 10px;
}
QPushButton:hover {
background-color: lightblue;
color: black;
}
QPushButton:pressed {
background-color: darkblue;
color: white;
}
```
In this example, we're setting the background color, text color, border style, border radius, and padding for the QPushButton. We're also adding styles for when the button is hovered over or pressed.
You can customize the QSS to your liking and apply it to your QPushButton using the setStyleSheet() function.
阅读全文