I tried to make a custom QWidgetAction. That works fine.
However... on windows with different DPI the font in the menu changes in non-obvious ways.
- 100% -> pointSize = 8
- 125% -> pointSize = 9
- 150% -> pointSize = 9
(so I was not able to fit some linear function).
I am going through Qt sources to find where the font size is set, but no luck (so far).
Maybe someone can point me to the place where the font size is set depending on DPI? (So that I can use the same calculation for my custom widget.
Thanks, guys.
Add
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);in main.cpp and check again I think this will fix your problem.also, this doc explains it more.
Edited:
For a setting font to
QLabelyou can do this in two ways :QFontobject and add the same menu font to it then with the setFont function of QLabel add it.Default font size for all widgets and QMenu in Qt is 11.