Oversized Qt Fonts on OSX

Why is Qt on OSX too large by default? Even when you select the same font size manually, the fonts look a little larger. Qt on OSX uses a different font for OSX? Does this improve if you use Qt for Cocoa?

Also, is there a qtconfig tool or its equivalent to globally set font options for all Qt applications?

Thanks!

+3
source share
3 answers

Why is Qt on OSX displaying too large fonts by default?

By default, the same fonts are used in InterfaceBuilder and Qt Designer.

Even if you select the same font size manually, the fonts displayed are slightly larger.

, , .

Qt OSX OSX?

, .

, Qt Cocoa?

, . Carbon Cocoa, -, .

, qtconfig Qt?

qtconfig OSX .

, , OSX Windows Linux. , Qt OSX, , , .

+1

. OS X . , .

OS X , , , , OS X.

, Qt , : Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, Qt::WA_MacMiniSize, Qt::WA_MacVariableSize - , , , , , - , , #ifdef ( ).

, Qt Qt Creator Qt Designer, , , , , .

+2

AS , : Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, Qt::WA_MacMiniSize, Qt::WA_MacVariableSize.

The easiest way I found for your entire application is to use QProxyStyle and QProxyStyle::polishset the attribute in the method the way you want.

Usually I’m sure that I DO NOT change the flags on QMenu widgets, as it interrupts the display of keyboard shortcuts.

So, for example, to make all widgets small, except for menus and those that I prefer to stay large, I do:

void QMveStyle::polish ( QWidget * w )
{
#ifdef __APPLE__
    QMenu* mn = dynamic_cast<QMenu*>(w);
    if(!mn && !w->testAttribute(Qt::WA_MacNormalSize))
        w->setAttribute(Qt::WA_MacSmallSize);
#endif
}
0
source

Source: https://habr.com/ru/post/1713624/


All Articles