summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-26 16:34:48 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-03-01 09:56:14 +0000
commitdaa39f84996700d2459d8e570ac1b3f2f2cdffd0 (patch)
tree43c71dfc6421e192c5d056bbb9893bd77441ec80 /src
parent9f77854d284cf6cd209d8055400c04ca8312c3f3 (diff)
ToolTip/Windows: Fix wrong size when font is modified by widget stylesheet
Factor out a function to calculate the size and update the size when a style sheet parent is set. Task-number: QTBUG-64550 Change-Id: I3afe997085eae3cd48b7fe0a4c98582a8f572260 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qtooltip.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 69b62ff7d7..baf717d715 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -127,6 +127,8 @@ public:
~QTipLabel();
static QTipLabel *instance;
+ void updateSize();
+
bool eventFilter(QObject *, QEvent *) override;
QBasicTimer hideTimer, expireTimer;
@@ -214,13 +216,18 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime)
setWordWrap(Qt::mightBeRichText(text));
setText(text);
+ updateSize();
+ restartExpireTimer(msecDisplayTime);
+}
+
+void QTipLabel::updateSize()
+{
QFontMetrics fm(font());
QSize extra(1, 0);
// Make it look good with the default ToolTip font on Mac, which has a small descent.
if (fm.descent() == 2 && fm.ascent() >= 11)
++extra.rheight();
resize(sizeHint() + extra);
- restartExpireTimer(msecDisplayTime);
}
void QTipLabel::paintEvent(QPaintEvent *ev)
@@ -387,6 +394,9 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
if (w) {
connect(w, SIGNAL(destroyed()),
QTipLabel::instance, SLOT(styleSheetParentDestroyed()));
+ // QTBUG-64550: A font inherited by the style sheet might change the size,
+ // particular on Windows, where the tip is not parented on a window.
+ QTipLabel::instance->updateSize();
}
}
#endif //QT_NO_STYLE_STYLESHEET