Bug 496930

Summary: QMenu does not wrap contents at screen height
Product: [Plasma] Breeze Reporter: Frankystone <somal>
Component: QStyleAssignee: Plasma Bugs List <plasma-bugs-null>
Status: REPORTED ---    
Severity: normal CC: nate, noahadvs, uhhadd
Priority: NOR    
Version First Reported In: 6.2.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: kde support information
Program for demonstration

Description Frankystone 2024-12-02 14:15:55 UTC
Created attachment 176288 [details]
kde support information

The application qmapshack uses a QMenu to provide a list of items to change a waypoint icon. This list contains 121 items.
During porting qmapshack to Qt6 a strange behavior has been encountered:
The Qt 5 version of qmapshack shows on my machine a single column containing all entries and the single column can be scrolled.
The Qt6 version of qmapshack shows also a single column on my machine, but scrolling does not work.
See image here: https://github.com/Maproom/qmapshack/issues/648#issuecomment-2475741222

On other machines (e.g. using windows or Tuxedo OS(Ubuntu based)) the list of waypoint icons are wrapped into multiple columns for the Qt5 and the Qt6 version of qmapshack, so scrolling isn't needed at all. See image here: https://github.com/Maproom/qmapshack/issues/648#issuecomment-2475752824
If i use oxygen as application style the entries in the QMenu are wrapped and i get also a multi-column list, while using breeze there is only a single column.

While examining this issue i found that executing QMenu->addAction() produces different results for QMenu.sizeHint():
oxygen: if the screen.height (1080px in my case) is reached, the width of sizeHint will be adjusted (a column get added)
breeze: all items change only the height of sizeHint (just one column)

In result the values of sizeHint are:
oxygen: sizeHint() = QSize(696, 1075)
breeze: sizeHint() = QSize(252, 3154), the resulting window will exceed the screen height.

This happens also in a clean environment, eg by starting qmapshack as a new created user.

The corresponding code of qmapshack can be found here: https://github.com/Maproom/qmapshack/blob/23d6fe3e11bd251f123fdba1f1cf2ac8170d4f83/src/qmapshack/helpers/CWptIconManager.cpp#L297

STEPS TO REPRODUCE
1. Try to change a waypoint icon in qmapshack  (do not know which application might also have such a QMenu)

OBSERVED RESULT
There is only a single column for all waypoint icons exceeding the screen height.

EXPECTED RESULT
The items in the list of waypoint icons should wrap, so multiple columns are shown and the resulting window should fit onto the screen.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: up to date archlinux
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0 
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Scaling is not used.
kde support info can be found in the attachment
Comment 1 Frankystone 2025-02-05 13:31:28 UTC
Created attachment 177989 [details]
Program for demonstration

The attached program shows the the issue without the need to install QMapShack. The base files were taken from https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/mainwindows/menus?h=6.8 , i have just added some more menu entries. After compiling just do a right click in the window.