Hello,

I'm looking for a solution to append single characters to QTextEdit with different colors.
I tried the following:

Qt Code:
  1. QTextCursor curs(textCursor());
  2. fmt.setForeground(QBrush(Qt::red));
  3. curs.setCharFormat(fmt);
  4. curs.movePosition(QTextCursor::End);
  5. curs.insertText(QString(chr));
To copy to clipboard, switch view to plain text mode 
does not work

Qt Code:
  1. setTextColor(kolor1);
  2. append(QString(chr));
To copy to clipboard, switch view to plain text mode 
does not work either

The only thing that actually works, is the <font> tag
Qt Code:
  1. append(QString("<font color=red>%1</font>").arg(chr));
To copy to clipboard, switch view to plain text mode 

The problem is, I'm getting the input char by char, and cannot combine it into QString easily; every new character could have a different color. I would like to find a way other than tagging every single character (which would yield tons of garbage text not seen by the user, and would be probably not speed efficient).

It would be nice, if QTextEdit remembers the last color setting, and appends new characters with that color...