From 114c4593b6950122ad10326903c986647adb2dc0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 26 Sep 2018 13:26:03 +0200 Subject: Restore styling of QDockWidget title font Do not override a custom font with the style default. Task-number: QTBUG-70276 Change-Id: I58bf43f791aee5409e29459d579725365703e4f3 Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 0b2eee7180..6c871aae2c 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -696,7 +696,6 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const // If we are in a floating tab, init from the parent because the attributes and the geometry // of the title bar should be taken from the floating window. option->initFrom(floatingTab && !isFloating() ? parentWidget() : this); - option->fontMetrics = QFontMetrics(d->font); option->rect = dwlayout->titleArea(); option->title = d->fixedWindowTitle; option->closable = hasFeature(this, QDockWidget::DockWidgetClosable); @@ -1473,6 +1472,7 @@ void QDockWidget::closeEvent(QCloseEvent *event) void QDockWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) + Q_D(QDockWidget); QDockWidgetLayout *layout = qobject_cast(this->layout()); @@ -1493,7 +1493,11 @@ void QDockWidget::paintEvent(QPaintEvent *event) // the title may wish to extend out to all sides (eg. Vista style) QStyleOptionDockWidget titleOpt; initStyleOption(&titleOpt); - p.setFont(d_func()->font); + if (font() == QApplication::font("QDockWidget")) { + titleOpt.fontMetrics = QFontMetrics(d->font); + p.setFont(d->font); + } + p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); } } -- cgit v1.2.3