Nominate our 2022 Qt Champions!

QFont fixed width numbers with Windows Arial font

  • Hi,

    porting my Windows MFC desktop program to Qt5.4 I got the problem that in Qt numbers are drawn not in fixed width, but in MFC they are.

    Never got this problem before. Usually numbers in proportional Windows fonts are drawn with fixed width.

    The Font here is Windows Arial and the numbers were drawn with QPainter, QFont and QPainter::drawText().

    (Like above Qt draws the "1" with less width, MFC draws all numbers with same width)

    How to draw numbers with Arial font in Qt5 with fixed width?

  • I tested different programs with Windows "Arial" font:

    Microsoft Windows 7 "Wordpad": Numbers are fixed width
    Microsoft C++ MFC program via GDI+: Numbers are fixed width.
    Libre Office: Numbers are not fixed width
    Qt via QPainter: Numbers are not fixed width

    But with "Microsoft Sans Serif" all above programs are showing numbers with fixed width - strange.

    So I stay with "Microsoft Sans Serif" - problem solved.

Log in to reply