"Bold" style is not available for "Sans Serif" font on QT5

352 Views Asked by At

We just moved our application from QT4 to QT5. We found the "Bold" style is not avialble for "Sans Serif" font on QT5. I can tell from the QFontDialog which looks below: enter image description here

I also use the following code to dump all available styles under "Sans Serif"

QFontDatabase db;
auto list = db.styles("Sans Serif");
for(auto& l : list)
    std::cout << l << " ";

And I got the same list which is Normal, Italic and Oblique. However I can see the Bold and Bold Italic options on QT4. My question is how the mapping from font to font style is implemented. Am I able to configure something to make the "Bold" avalialble for "Sans Serif" font in QT5.

1

There are 1 best solutions below

0
On

Is it possible that is selects a different font? (note, Sans Serif is a general name, actual font associated may differ from system to system, from what was included into distribution of OS, from hardware, or from version to version of Qt).

At least when dealing with QSS styles, with Qt Quick and etc. it follows same rules as LaTex, where Sans Serif and Bold combinations are deprecated (actually Italic is too, it is same as just choose an Italic font). If you want an equivalent , you likely have to use Helvetica with Bold style (Helvetica is the usual typeface behind Sans Serif).

This is really depending on OS configuration.