我可以通过更改样式表来更改设计器中QPushButton的图像或任何其他样式,但样式表中的任何更改都会更改所有其他属性。
例如,当我更改边框图像时,其他所有内容都会更改,并且它不会从父项(或Windows样式)继承其余属性。
如何在仅更改图像时保持窗口样式?
答案 0 :(得分:0)
您是否尝试将样式设置为单个按钮:
your_push_button_pointer->setStyleSheet(
"QPushButton{background-image: url(:/images/call_up.bmp);}"
"QPushButton:hover{background-image: url(:/images/call_hov.bmp);}"
"QPushButton:pressed{background-image: url(:/images/call_down.bmp);}");
答案 1 :(得分:0)
来自How can I set Styles to a QTabwidget without overwriting existing styles in QT ?:
样式表全部或全部。所以,如果你们都应用样式表,那么 可能会重置一些小部件的外观并修复它,你 必须提供完整的样式表。
关键部分是:
您可以为 QPushButton from the code或使用 QtDesigner 设置图像: