Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5.3, 6.6.0
-
-
8cd7a3d47 (dev), 60d91acc0 (6.7), 19792c38e (6.6), dc43086e7 (tqtc/lts-6.5), 7aedcdefb (dev), 137706fc3 (6.7), a158a1807 (6.6), 3a4ea1c70 (tqtc/lts-6.5)
Description
Reproducer attached. One can adjust the number of entries to be shown in menu by entering numbers to QLineEdit, so that there are many enough to show the problem. Also, one needs 2 displays with different resolutions and sizes. The more different the displays are, the clearer the problem is. I suppose it is different DPI that causes the issue.
The issue is that if all menu entries on one display can be shown correctly, there can be some missing from another display. For example, I have 1920*1200 16-inch and 1920*1080 27-inch. Please find the screenshots. With Qt6, QMenu is sized correctly (there is another column), but entries are not arranged accordingly (Menu 49 ~ 54 are missing, and entries are not being placed in the 3rd column) on the 27-inch screen.
However, it does not happen to Qt5. See the screenshots, that entries are placed correctly into the 3rd column so that all of them are visible on the 27-inch screen.
Suspected cause:
In qmenu.cpp:
void QMenuPrivate::updateActionRects() const
{
updateActionRects(popupGeometry());
}
popupGeometry is called without argument.
Proposed fix:
Substitute the content of method by
Q_Q(const QMenu);
updateActionRects(popupGeometry(QGuiApplication::screenAt(q->pos())));
Maybe this needs fix too:
void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active) { ...... QRect screen = popupGeometry(); ...... }
Another "stupid" fix for it is to explicitly set a geometry for QMenu. For example, in the sample program, instead of
menu.exec(event->globalPos());
do this:
menu.setGeometry(event->globalX(), event->globalY(), 0, 0); menu.exec();
I don't know why it works, even with nonsense size 0-by-0.
Attachments
For Gerrit Dashboard: QTBUG-118434 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
516933,16 | Fix menu size in multiscreen setups | dev | qt/qtbase | Status: MERGED | +2 | 0 |
546193,2 | Fix menu size in multiscreen setups | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
546503,2 | Fix menu size in multiscreen setups | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
546520,2 | Fix menu size in multiscreen setups | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |
551731,2 | QMenu: clear popup screen after exec() | dev | qt/qtbase | Status: MERGED | +2 | 0 |
551763,2 | QMenu: clear popup screen after exec() | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
551834,2 | QMenu: clear popup screen after exec() | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
551996,2 | QMenu: clear popup screen after exec() | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |