Important: Please read the Qt Code of Conduct -

How to get the systems default sans serif monospace font?

  • Hi,

    Under Linux, when I create font and setFixedPitch on it, and get a nice monospaced font with no serifs. Under Windows I get Courier New. If I set styleHint() the font changes to non-fixed width.

    How can I get a fixed-width (monospaced) non-serif font under Windows (actually, all platforms).


    This doesn't work:

    QFont font("Mono", 12);

  • Lifetime Qt Champion


    You should add which version of Qt you are using on each platform.

  • Sorry, 5.14.1, I believe..

    I just told both Linux and Windows to load the Consolas font, and it works. Linux uses Deja Vu Sans Mono instead.


Log in to reply