QTextEdit 和QPlainTextEdit本身没有提供设置插入字体的颜色的API,可以自定义一个setInsertTextColor(const QColor & c)来实现:
void XXXX::setInsertTextColor(QColor col,BackOrFore wground)
{
QTextCharFormat fmt;
fmt.setForeground(col);
QTextCursor cursor = textCursor();
cursor.mergeCharFormat(fmt);
mergeCurrentCharFormat(fmt);调用QTextEdit或者QPlianTextEdit的api;
}