summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qtooltip.cpp
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2018-12-04 13:31:39 +0100
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2018-12-18 11:22:37 +0000
commit7fc427ba23a624a433d93e1c604d870656835305 (patch)
tree2485195ccaa2962bc5291636faaab35a4482ae6f /src/widgets/kernel/qtooltip.cpp
parent7863be311570fa219066df5fe8720d5b92ddb680 (diff)
QToolTip - set correct screen before resize
In order to get a correctly not truncated size we need the hint to be calculated based on the screen it is about to be shown on. This patch places some code in QWidgetPrivate that is used by QMenu and QToolTip + can be used to solve similar problems in the future. Task-number: QTBUG-72306 Change-Id: I58c058761f71b4a7675b6a078be62aa813ead752 Reviewed-by: Morten Kristensen <msk@nullpointer.dk> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/kernel/qtooltip.cpp')
-rw-r--r--src/widgets/kernel/qtooltip.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 2e6575c163..9d8b0062f5 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -41,6 +41,7 @@
#endif
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include <QtWidgets/private/qlabel_p.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
@@ -127,6 +128,7 @@ public:
~QTipLabel();
static QTipLabel *instance;
+ void adjustTooltipScreen(const QPoint &pos);
void updateSize(const QPoint &pos);
bool eventFilter(QObject *, QEvent *) override;
@@ -222,6 +224,12 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint
void QTipLabel::updateSize(const QPoint &pos)
{
+#ifndef Q_OS_WINRT
+ // ### The code below does not always work well on WinRT
+ // (e.g COIN fails an auto test - tst_QToolTip::qtbug64550_stylesheet - QTBUG-72652)
+ d_func()->setScreenForPoint(pos);
+#endif
+ // Ensure that we get correct sizeHints by placing this window on the right screen.
QFontMetrics fm(font());
QSize extra(1, 0);
// Make it look good with the default ToolTip font on Mac, which has a small descent.
@@ -229,6 +237,7 @@ void QTipLabel::updateSize(const QPoint &pos)
++extra.rheight();
QSize sh = sizeHint();
if (wordWrap()) {
+ // ### When the above WinRT code is fixed, windowhandle should be used to find the screen.
QScreen *screen = QGuiApplication::screenAt(pos);
if (!screen)
screen = QGuiApplication::primaryScreen();