发现checked状态图标不会改变,qproperty-icon设置对checked样式设置无效,无法实现自动切换;所以还是采用如下样式, 在代码里检测checked状态, 设置不同的样式。
如果没有文字,只是单独的图标,可以换成background-image:url(:/analysisCenter/Resources/analysisCenter/orderup.svg);可以正常改变,但是图标不会在文字左侧;
QPushButton { padding-left: 8px; font-family: Microsoft YaHei UI; font-size: 14px; color: rgba(255,255,255,0.7); line-height: 20px; border: 1px solid #8f8f8f; qproperty-icon: url(:/analysisCenter/Resources/analysisCenter/orderup.svg); qproperty-iconSize: 20px 20px; qproperty-toolButtonStyle: ToolButtonTextBesideIcon; } QPushButton:checked { padding-left: 8px; font-family: Microsoft YaHei UI; font-size: 14px; color: rgba(255,255,255,0.7); line-height: 20px; border: 0px; qproperty-icon: url(:/analysisCenter/Resources/analysisCenter/orderdown.svg); qproperty-iconSize: 20px 20px; qproperty-toolButtonStyle: ToolButtonTextBesideIcon; }
标签:analysisCenter,qproperty,font,选中,QPushButton,20px,图标,255 From: https://www.cnblogs.com/bclshuai/p/18205636