我有一个QMenuBar在我的pyqt5应用程序,我正试图costumize。我只想用id='update'更改一个QAction的颜色,其他QAction保持不变,但它没有按我想要的那样工作。以下是我所拥有的:
self.update_btn = self.menu.addAction('Update')
self.update_btn.setVisible(True)
self.update_btn.setObjectName("update")
self.menu.setStyleSheet(
"""
QMenuBar > QAction#update) {
background: red;
}
""")
我试过其他几种方法,但都不管用
QAction不支持样式表
您可以使用QWidgetAction
试试看:
相关问题 更多 >
编程相关推荐