Qt: The same control displays fonts of different colors

           *QString str1="测试";
           QString str2="修改";
           QString strText =str1+str2;
           if(!strText.isEmpty())
           {
    
    
               QRegExp valueRegExp(QString("(%1)").arg(str2));
               valueRegExp.setCaseSensitivity(Qt::CaseInsensitive);
               strText = strText.replace(valueRegExp, "<font style='color:blue;'>\\1</font>");
           }
           ui->label_3->setText(strText);
          qDebug()<<strText<<endl;*

insert image description here
The output of strText is as follows:
insert image description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324217350&siteId=291194637