4

I have a GUI with some math symbols that might be hard to read at the default font size, so I would like to create a QFont object that has a size of system_default+4.

However, there doesn't seem to be a way to get the default size in the first place, and I don't want to hardcode a size that might be even smaller than what the user is using.

LtWorf
  • 7,286
  • 6
  • 31
  • 45

1 Answers1

4

This question and answer How do you get the system default font size in Qt? suggests that a QFont object starts with the system default. Also, the API docs indicate that the default QFont constructor does this (http://doc.qt.io/qt-5/qfont.html#QFont), and also suggests QGuiApplication::font() as another way to get the default font.

So you could do something like

QFont f;
int defaultFontSize = f.pointSize();

to obtain the system default. To increase the font size just increment this value by 4, create a QFont with this size (or use setPointSize to modify an existing font obj), and set the font on the label displaying your math symbols.

Community
  • 1
  • 1
trooper
  • 4,444
  • 5
  • 32
  • 32