Dynamic change of font color in QtSerialPort-Terminal-Example
Solved
General and Desktop
-
Hello
I'm trying to change color of the serial-port-input/output characters in the QtSerialPort-Terminal-Example.
My problem is that QPalette::setColor
or
setStyleSheet("color: rgb(255,255,255)");
always changes the whole displayed text, but I want different colors for keyboard input and serial output.Is this possible?
-
Hi and welcome to the forums.
yes you can but you have to manipulate the structure and not the palette as that is used for all text so
its a no go. (also stylesheet)QTextCharFormat tf = ui->plainTextEdit->currentCharFormat(); tf.setForeground(QBrush(Qt::red)); ui->plainTextEdit->setCurrentCharFormat(tf); ui->plainTextEdit->appendPlainText("test");
I think you can also use HTML.
https://stackoverflow.com/questions/52074120/qplaintextedit-with-multiple-colours-on-a-line