Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the system default font size in Qt?

Tags:

fonts

qt

Qt uses 9px as default font size, but users (on Linux) can change this by using qtconfig.

So, how do I get the system default font size? I read the documents, but I can not find any API.

like image 533
比尔盖子 Avatar asked Mar 02 '13 15:03

比尔盖子


People also ask

How do I change the default font in Qt?

Simply use the setFont() method on the QApplication or QWidget : QFont font("Courier New"); font. setStyleHint(QFont::Monospace); QApplication::setFont(font);

How do you set font size to its default size?

To set your computer's displayed font size to default: Browse to: Start>Control Panel>Appearance and Personalization>Display. Click Smaller - 100% (default).

What is the default value of font size?

1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px.

Why is default font size 16?

[16 pixels] is not big. It's the text size browsers display by default. It's the text size browsers were intended to display… It looks big at first, but once you use it you quickly realize why all browser makers chose this as the default text size.


2 Answers

Your application default font can be obtained from QApplication::font(), which

Returns the default application font.

And you can gather a size of it using pointSize(),pointSizeF(),pixelSize(), etc.

like image 95
PolyGlot Avatar answered Oct 25 '22 07:10

PolyGlot


Get a default font QFont object and read the size from it.

like image 43
ypnos Avatar answered Oct 25 '22 08:10

ypnos