PDA

View Full Version : Qt submenu offset issue



Alundra
4th October 2015, 20:59
Hi,
I added a bug in the bug reports here :
https://bugreports.qt.io/browse/QTBUG-47032
Is it possible to solve this issue before a fix of Qt ?
If possible, how solve it ?
Thanks

Alundra
8th October 2015, 23:04
I tried to use stylesheet but no effect, maybe I did badly ?

Kryzon
9th October 2015, 01:04
All the sub-menus in all the software here under Windows 8.1 seem to have the same behaviour, even in non-Qt software.

Check other applications for yourself, like your web browser; I think this is from the OS.

Alundra
9th October 2015, 12:20
No way to change that to have it on the same height as the first menu and to not have the offset on the left ?

d_stranz
9th October 2015, 17:33
On Windows 10, it is a bit different - in Firefox and Notepad++, submenus are offset about 5-10 pixels or so to the left, and about the same amount higher than the parent menu item. In Qt Assistant, the submenus are also offset to the left by about 10 pixels, but are aligned with the top of the parent menu item. In a Qt 5.4 app I have written, submenus have no offsets, either horizontally or vertically. That indicates it may not be an OS-controlled behaviour.

Kryzon
9th October 2015, 21:05
Aren't the menu panels in Qt just QWidgets emulating the style of the OS?

I'd look into styling the sub-menus position attributes: http://doc.qt.io/qt-5/stylesheet-reference.html#left-prop
You can style individual widgets by giving them an object-name with setObjectName( "bla" ), then using "QMenu#bla" to identify that widget in the style sheet. You would style every single sub-menu.

Alundra
10th October 2015, 01:38
I solved the visual issue removing the margin on the QMenu stylesheet and not doing a border on the top like that :

border-width: 0 1px 1px 0;
I added the info on the qt bug ticket here : https://bugreports.qt.io/browse/QTBUG-47032
Qt should take account of it for sub-menu.

anda_skoa
10th October 2015, 10:20
In a Qt 5.4 app I have written, submenus have no offsets, either horizontally or vertically. That indicates it may not be an OS-controlled behaviour.

It might not be controlled by the OS/windowing system but it could be part of the platform's style or style guidelines. In which case software not using the native menus will have different accuracy of following these.

A good idea when running into unexpected visualization is therefore to run with a different style plugin and, as already mentioned, to look at other, non-Qt software.


Aren't the menu panels in Qt just QWidgets emulating the style of the OS?

Depends.

In general all widget based UI in a Qt application is drawn by Qt and styled using plugins.
If there is a plugin for the specific platform then it might be very close to what the native UI components would do, if it is a cross platform style (e.g. fusion) then not.

But the Qt Platform Abstraction module can also provide special integration for menus and menu bars.

Cheers,
_