QTextEdit

一、设置颜色,支持html语言格式的

     ui->textEdit->append("<font color=\"#FF0000\">红色字体</font> ");

    信息显示用到,错误的红色字体

   光标移到后面

teMsg_->moveCursor(QTextCursor::End); 
void MainWidget::slotShowMsg(MainWidget::MsgType type,QString msg)
{
    if(type==MSG_ERROR)
    {
       msg="<font color=\"#ff0000\">"+msg+"</font>";
    }

    teMsg_->append(QDateTime::currentDateTime ().toString ("[yyyy/MM/dd hh:mm:ss zzz] ")+msg);

    logCount_++;
    if(logCount_>LOG_MAX_SIZE)
    {
        teMsg_->clear();
        logCount_=0;
        //qDebug()<<"clear";
    }

    teMsg_->moveCursor(QTextCursor::End);


}

 

posted @ 2020-03-07 10:22  ike_li  阅读(272)  评论(0编辑  收藏  举报