门户网站团队建设,wordpress 鼠标特效,什么是销售型网站,河南省建设厅网站同时设置QPushButton的文字样式和图标的方法 为了美化界面#xff0c;有时候需要修改QPushButton的样式#xff0c;让一个QPushButton上面既要显示图标#xff0c;又要显示文字内容 起初我的做法是重写QPushButton#xff0c;这样做可以实现#xff0c;但是有几个问题 实现…同时设置QPushButton的文字样式和图标的方法 为了美化界面有时候需要修改QPushButton的样式让一个QPushButton上面既要显示图标又要显示文字内容 起初我的做法是重写QPushButton这样做可以实现但是有几个问题 实现比较繁琐每次使用UI编辑器设计界面的时候对每一个QPushButton都要做一次提升 为了解决上面的问题就使用QSS的方式实现 QPushButton上面既显示文字又显示图标的需要 通过qss样式便可以在一个QPushButton上面左边显示图标右边显示文字 效果图 具体代码实现如下
QPushButton#btnUpdate{font: 9pt .萍方-简;font-style: normal;font-size: 12px;line-height: 20px;border-radius: 4px;background: rgb(0, 142, 250);color: #FFFFFF;text-align: right;padding-right: 16px;background-image: url(:/UpdateLauncher/Source/Check.png);background-origin: content;background-position: left;padding-left: 16px;background-repeat: no-repeat;
}
QPushButton#btnUpdate:hover{font: 9pt .萍方-简;font-style: normal;font-size: 12px;line-height: 20px;border-radius: 4px;background: rgb(0, 100, 250);color: #FFFFFF;text-align: right;padding-right: 16px;background-image: url(:/UpdateLauncher/Source/Check.png);background-origin: content;background-position: left;padding-left: 16px;background-repeat: no-repeat;
}
QPushButton#btnUpdate:pressed{font: 9pt .萍方-简;font-style: normal;font-size: 12px;line-height: 20px;border-radius: 4px;background: rgb(0, 142, 250);color: #FFFFFF;text-align: right;padding-right: 16px;background-image: url(:/UpdateLauncher/Source/Check.png);background-origin: content;background-position: left;padding-left: 16px;background-repeat: no-repeat;
}