qdialog标题栏按钮图片样式
时间: 2023-12-12 21:04:21 浏览: 232
您可以使用QSS(Qt Style Sheet)来设置QDialog标题栏按钮的图片样式。以下是一个示例:
```python
# 设置关闭按钮样式
self.setWindowFlags(Qt.WindowCloseButtonHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setStyleSheet('''
QDialog {
background-color: rgba(255, 255, 255, 0%);
border: 1px solid #d9d9d9;
}
QDialog::title {
background-color: #f5f5f5;
height: 35px;
font-size: 14px;
border: none;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
color: #333333;
font-weight: bold;
}
QDialog::close-button {
border: none;
background-image: url(":/images/close.png");
background-repeat: no-repeat;
background-position: center;
width: 25px;
height: 25px;
}
QDialog::close-button:hover {
background-color: #f44336;
border-radius: 12.5px;
}
''')
```
在这个例子中,我们设置了关闭按钮的样式为一个图片,当鼠标悬停在按钮上时,它会显示一个红色的圆形背景。您需要将“:/images/close.png”替换为您自己的图片路径。
此外,我们还设置了QDialog的标题栏样式。您可以根据需要调整这些值来满足您的需求。
阅读全文
相关推荐















