title: QPainter, assigning different colors to text parts
body: <p>I have the below code to display some text via <code>QPainter</code></p>
  
  <pre><code>QPainter painter(this);
  painter.setRenderHint(QPainter::Antialiasing);
  painter.setPen(QColor(10, 10, 10, 255)); // text color
  painter.fillRect(QRect(10, 10, 200, 100), QColor(100, 100, 100, 120)); //rectangular color
  painter.setFont(font);
  painter.drawText(20, 20,  "1 2 3 4");
  </code></pre>
  
  <p>I want to display each part of the text via different color, e.g. <code>1</code> in black, <code>2</code> in white, <code>3</code> in blue, and <code>4</code> in red. All the text should be in the same line. How can I do it?</p>