QTextCharFormat myFormat;
myFormat.setFontWeight(QFont::Bold);
myFormat.setForeground(Qt::green);
QString pattern="\\bchar\\b";
QRegExp expression(pattern);
int index=text.indexOf(expression);
while(index>=0)
{
int length=expression.matchedLength();
setFormat(index,length,myFormat);
index=text.indexOf(expression,index+length);
}
QString patt="\\bdouble\\b";
QRegExp express(patt);
int inde=text.indexOf(express);
while(inde>=0)
{
int lengt=express.matchedLength();
setFormat(inde,lengt,myFormat);
inde=text.indexOf(express,inde+lengt);
}