0
QTextCharFormat tf;
tf = m_txtLog->currentCharFormat();
tf.setForeground(QBrush((Qt::GlobalColor)7));
tf.setTextOutline(QPen((Qt::GlobalColor)7));
m_txtLog->setCurrentCharFormat(tf);

m_txtLog->appendPlainText("RED");

Text will become red after the code above. but the color will disappear after I copy the colored text into Notepad.

I don't know why and please help me how to do it to keep the colored text. The QT version is QT4.8.1

Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
Marko Ma
  • 3
  • 5
  • 2
    Notepad (if it is the one of Windows) does not support any kind of rich text. Hence, your colored text is converted to plain text (losing all color or other formatting info) when copy/pasted. In a rich text capable text editor (e.g. MS Word) it would work. (I just tried out of curiosity.) – Scheff's Cat May 22 '18 at 07:40
  • Yes. MS Word works. Thank you Scheff. – Marko Ma May 22 '18 at 08:06

0 Answers0