Fix QMenu size on first show
QWidget::metric is used to calculate the size of the menu, but it only respects a sceen from a Window handle, so we need to make sure such a thing is created. Task-number: QTBUG-103309 Pick-to: 6.2 6.3 Change-Id: Ie73e362cdcb3b59f46ad51c4901fdbeda7258baa Reviewed-by: Morten Kristensen <me@mortens.dev> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
6b02c85f87
commit
468b33d8f8
@ -2315,6 +2315,15 @@ void QMenuPrivate::popup(const QPoint &p, QAction *atAction, PositionFunction po
|
||||
lastContextMenu = contextMenu;
|
||||
}
|
||||
|
||||
// Until QWidget::metric accepts the screen set on a widget (without having a window handle)
|
||||
// we need to make sure we get a window handle. This must be done near here because
|
||||
// we want the screen to be correctly set and items to be marked dirty.
|
||||
// (and screen set could 'fail' on oldscreen == newScreen if created before causing the
|
||||
// itemsDirty not to be set though needed to get the correct size on first show).
|
||||
if (!windowHandle()) {
|
||||
createWinId();
|
||||
}
|
||||
|
||||
#if QT_CONFIG(menubar)
|
||||
// if this menu is part of a chain attached to a QMenuBar, set the
|
||||
// _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type
|
||||
|
Loading…
x
Reference in New Issue
Block a user