Just a quick addition: an alternative to generating the html yourself, if you’re populating the text box programatically, is to use textEdit->setTextColor(QColor&)
. You can create the QColor object yourself, or use one of the predefined colours in the Qt namespace (Qt::black, Qt::red, etc). It will apply the specified colour to any text you add, until it is called again with a different one.