一、设置颜色,支持html语言格式的
ui->textEdit->append("<font color=\"#FF0000\">红色字体</font> ");
信息显示用到,错误的红色字体
void MainWidget2::slotShowMsg(MsgType type,QString msg) { logSize_++; msg=QDateTime::currentDateTime ().toString ("[yyyy/MM/dd hh:mm:ss zzz] ")+msg; if(type==L_ERROR) { ui->teMsg->append("<font color=\"#FF0000\">"+msg+"</font>"); } else { ui->teMsg->append(msg); } if(logSize_>LOG_MAX_SIZE) { ui->teMsg->clear(); logSize_=0; } }
原文:https://www.cnblogs.com/ike_li/p/12432882.html