From 65656e03896d12c6dbc37a2ae7d30ec257c26092 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 21 Mar 2014 09:34:47 +0100 Subject: QPushButton: draw label using the stylesheet's font. The RenderRule for the stylesheet has the correct font information, it just wasn't being set on the painter that draws the label. This is a backport of the Qt 5 commit: 9ad768fd1999780df18551151b9d9fa9c354131c. Task-number: QTBUG-8990 Change-Id: I4857d6e17b62980782ca7bfdfd0a571a9950f635 Reviewed-by: Gabriel de Dietrich --- src/gui/styles/qstylesheetstyle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index bbda15b..61fdbcf 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3378,6 +3378,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (const QStyleOptionButton *button = qstyleoption_cast(opt)) { QStyleOptionButton butOpt(*button); rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); + + const QFont oldFont = p->font(); + if (rule.hasFont) + p->setFont(rule.font); + if (rule.hasPosition() && rule.position()->textAlignment != 0) { Qt::Alignment textAlignment = rule.position()->textAlignment; QRect textRect = button->rect; @@ -3450,6 +3455,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q } else { ParentStyle::drawControl(ce, &butOpt, p, w); } + + if (rule.hasFont) + p->setFont(oldFont); } return; -- cgit v0.12