Default Fixed Width Font in Qt

Is there a cross-platform way to get the user preferred fixed and proportional fonts in Qt?

For example, Cocoa has

NSFont *proportional = [NSFont userFontOfSize:12.0f]; NSFont *fixed_width = [NSFont userFixedPitchFontOfSize:12.0f]; 

I would like to find an equivalent in Qt that works on Mac, Linux, and Windows.

+4
source share
1 answer

Using the QFontDatabase systemFont (..) function, you can get

  • system default font
  • fixed default font
  • font "title"
  • smallest readable font

Example:

 const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont) 

Introduced in Qt 5.2

+6
source

All Articles