Important: Please read the Qt Code of Conduct -

QPainter::drawText(QRectF ...) draws with very unequally spaces between the characters

  • Hi!
    When I use the font "Corbel" and draw a text like the following

    QRectF testRectF = QRectF(QPointF1, QPointF2);
    painter->drawText(testRectF, Qt::AlignVCenter | Qt::AlignLeft, "some text");

    I get really ugly results like the following

    0_1525344174258_Qt 33.png
    There is more space between the 'i' and the 'a' for example than between the words "counter" and "variable" (there is a actual space between them, not between the 'i' and the 'a'). So, the spaces between the characters are very unequally.
    When I use the font Arial, it is better, but still wrong, so it's not the font itself.
    Has anyone an idea what the problem could be?

  • Lifetime Qt Champion


    IIRC, you need to use a monospaced font for that kind of use case.

    Hope it helps

Log in to reply