PDA

View Full Version : How do I get a QMenu to react to font size changes on High DPI diplays



mikag
20th July 2015, 16:47
Testing High DPI support in Qt and I ran into an issue before I even got my test program done.
The test is trivial, just a mainwindow with menu bar and a toolbar with actions.

As I drag the program to and from the High DPI display the font size for menus change just as expected. But the size of the menu items don't update resulting in text that doesn't fit. This is just using the menus created by default in a mainwindow project in Creator.
I naively thought menus would update layouts and sizes automatically when the text or fonts changed.

11287

Is there a way to get the menu bar to update when the font size changes due to moving the window to and from a High DPI screen?

And as a follow up, is there any way to get the images in the actions both on the toolbar and menu items to change size depending on screen dpi?

I've looked at the High DPI section (http://doc.qt.io/qt-5/highdpi.html) in the 5.5 docs but I just don't understand how to apply what it say to the layout of menu bars and images attached to QActions. :confused:

Could this possibly be related to me using windows style rather then a fully Qt controlled style for the application? Must test this with a non windows style when I get the chance.

mikag
21st July 2015, 15:47
Finally got around to testing this with the included Fusion style and menus still doesn't resize properly when the menu font grows.
So if anyone have any experience with adopting widget based Qt apps for High Dpi displays I'd be so happy to hear what kind of solutions you used.