Tooltips: Fix widget tool tip positioning on macOS

There is a weird behavior of Qt on macOS, that widget tooltips are moved
up by 20 pixels when calling show().
This is pretty annoying, because the tooltip gets under the mouse
pointer and interrupts user interaction.

This only happens if all of

- the widget has multiple subwidgets
- the layout has size constraint QLayout::SetFixedSize
- adjustSize is called

are true.

Remove the explicit adjustSize, that doesn't seem to make any
difference, except for avoiding the issue with show().

Task-number: QTBUG-131479
Change-Id: I2285bf77b0980940b48ac22f931a45b6a73ad06e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2024-11-22 13:36:40 +01:00
parent 01cc0e7499
commit 767b41f80f
2 changed files with 4 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
#include "tooltip.h"
#include "../qtcassert.h"
#include "../hostosinfo.h"
#include <QColor>
#include <QFontMetrics>
@@ -249,7 +250,8 @@ void WidgetTip::configure(const QPoint &pos)
move(pos);
m_layout->addWidget(m_widget);
m_layout->setSizeConstraint(QLayout::SetFixedSize);
adjustSize();
if (!HostOsInfo::isMacHost()) // work around QTBUG-131479
adjustSize();
}
void WidgetTip::pinToolTipWidget(QWidget *parent)

View File

@@ -463,6 +463,7 @@ DebuggerToolTipWidget::DebuggerToolTipWidget(DebuggerEngine *engine,
auto mainLayout = new QVBoxLayout(this);
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
mainLayout->addWidget(toolBar);
mainLayout->addWidget(treeView);