Important: Please read the Qt Code of Conduct -

Rendering issue of QPainter drawText method

  • I'm using QPainter and drawText method to draw text. Sometimes appears weird text rendering issue. I cannot find out any dependencies. It's interesting that only some letters are deformed. Have anyone ever noticed such problems before?

    Look at inscription at the bottom of the picture.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you using the same font for all drawing ? Is it the same string that use to draw both texts (the one that seem to be similar) ?

  • Are you drawing this text in QWidget or QGraphicsItem? I suppose that you are reimplementing some protected function. Which one?

    QWidget documentation: painting using a QPainter can only take place in a paintEvent() or a function called by a paintEvent()

    You should consider whether to use dedicated classes for drawing text like QLabel or QGraphicsSimpleTextItem.

Log in to reply