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().

    Example:
    12:42:15
    32:12:28
    11:11:11
    (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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.