path: root/src/gui/text/qcssparser_p.h
diff options
authorRichard Moe Gustavsen <>2019-10-10 14:33:53 +0200
committerRichard Moe Gustavsen <>2019-11-14 20:28:35 +0100
commit01ec11507d7ef3de09bad9d1ef8e6d4a3d6c4428 (patch)
tree10371581dfcbc8e47955a07fa14376e3c4a351ad /src/gui/text/qcssparser_p.h
parenta4751f8824723acaee4b9d8aa78a59c2aa36cb3e (diff)
QStyleSheetStyle: add new property to QPushButton: icon
There is currently no proper way to change the icon of a pushbutton from css. But there is a need for doing so (QTBUG-2982), and the typical work-around is to instead use the css property 'qproperty-icon'. But setting qproperties from the style is not a good idea in the first place, since it modifies the state of the widget it draws. Moreover, such properties are only set once (in QStyle::polish()), and will not have any effect on pseudo states, like hover. To close this gap, this patch will add a css property 'icon' that can be set on a QPushButton. This property will follow normal css cascading, and respect pseudo states, equal to any other css property. [ChangeLog][QtWidgets][QStyle] You can now set the CSS property 'icon' on a QPushButton to override which icon to draw. Fixes: QTBUG-79137 Change-Id: Ie7e0b0fa4f19471f51108cd4ca931356219d562e Reviewed-by: Christian Ehrlicher <> Reviewed-by: Jan Arve Sæther <>
Diffstat (limited to 'src/gui/text/qcssparser_p.h')
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index ab85e76cf3..b8bf259dda 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -198,6 +198,7 @@ enum Property {
+ QtIcon,
@@ -855,6 +856,7 @@ struct Q_GUI_EXPORT ValueExtractor
bool extractPalette(QBrush *fg, QBrush *sfg, QBrush *sbg, QBrush *abg);
int extractStyleFeatures();
bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
+ bool extractIcon(QIcon *icon, QSize *size);
int lengthValue(const Declaration &decl);