Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     QTextCursor highlightCursor(document);
  2.     QTextCursor cursor(document);
  3.  
  4.     cursor.beginEditBlock();
  5.  
  6.     QTextCharFormat plainFormat(highlightCursor.charFormat());
  7.     QTextCharFormat colorFormat = plainFormat;
  8.  
  9.     colorFormat.setBackground(Qt::yellow);
  10.  
  11.     while (!highlightCursor.isNull() && !highlightCursor.atEnd())
  12.     {
  13.     //       p.setColor(QPalette::Base, QColor("#f8f8f8"));
  14.     //XXX     if (searchTextList.contains())
  15.        
  16.         if (!highlightCursor.isNull())
  17.         {
  18.         count++;
  19.         // QTextDocument::FindCaseSensitively, wholeword 는 QTextDocument::FindWholeWords임
  20.         highlightCursor = document->find(strsearch,  highlightCursor, 0);
  21.         highlightCursor.movePosition(QTextCursor::WordRight,  QTextCursor::KeepAnchor);
  22.         highlightCursor.mergeCharFormat(colorFormat);
  23.         isSearch = true;
  24.         }
  25.     }
  26.     cursor.endEditBlock();
  27.  
  28.     if (isSearch)
  29.         searchTextList.append(strsearch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement