设置QPushButton想要设置pressed状态的图标,但是尝试了很多次都没有效果,原来是按照优先级来的,位置越往下优先级越高,hover状态时在最下面,所以鼠标在按钮上时,hover优先级最高,所以无论pressed还是checked都无法显示正确的图标,所以要调整下顺序;
QPushButton { border-image:url(:/analysisCenter/Resources/analysisCenter/trianglenormal.svg); } QPushButton:checked { border-image:url(:/analysisCenter/Resources/analysisCenter/triangleselect.svg); } QPushButton:pressed { border-image:url(:/analysisCenter/Resources/analysisCenter/triangleselect.svg); }
QPushButton:hover { border-image:url(:/analysisCenter/Resources/analysisCenter/trianglehover.svg); }
调整顺序如下,将hover上移:
QPushButton { border-image:url(:/analysisCenter/Resources/analysisCenter/trianglenormal.svg); } QPushButton:hover { border-image:url(:/analysisCenter/Resources/analysisCenter/trianglehover.svg); } QPushButton:checked { border-image:url(:/analysisCenter/Resources/analysisCenter/triangleselect.svg); } QPushButton:pressed { border-image:url(:/analysisCenter/Resources/analysisCenter/triangleselect.svg); }
标签:analysisCenter,checked,svg,image,pressed,QPushButton,border,Resources From: https://www.cnblogs.com/bclshuai/p/18291795