Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QPainter how to draw text with different colors?
Kaluss last edited by
how could I draw text with different colors for e.g.
"One Two" where One is yellow and Two is red ?
zaps166 last edited by
You can use this:
QPainter painter(this); painter.setPen(Qt::yellow); painter.drawText(0, 20, "One"); painter.setPen(Qt::red); painter.drawText(QFontMetrics(painter.font()).size(Qt::TextSingleLine, "One ").width(), 20, "Two");
but maybe there are better solutions :)