QTextCursor tc,tc_first;QTextCharFormat f;f.setBackground(Qt::green);//_pEdit - это QPlainTextEditQString str("XXX");QTextDocument* pDoc = _pEdit->document();for(int position=0;;){ tc = pDoc->find(str,position,QTextDocument::FindCaseSensitively); if(tc.isNull()){ break; } tc.setCharFormat(f); if(tc_first.isNull()){ tc_first = tc; } position = tc.position()+str.length();}if(!tc_first.isNull()){ tc_first.clearSelection(); _pEdit->setTextCursor(tc_first);}