Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [closed] Need implementation of Find & Replace option similar to QtCreator IDE

[closed] Need implementation of Find & Replace option similar to QtCreator IDE

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haney
    wrote on last edited by
    #1

    Hi,

    I am implementing find & replace option for my text editor application. I want the find & replace behavior similar to the find & replace option implemented in QtCreator IDE latest one.

    I am able to find word and replace word but how to set some background color to the found word or replaced word.

    I tried this.
    @
    if(textEdit->find(findLineEdit->text(), QTextDocument::FindCaseSensitively))
    {
    textEdit->insertPlainText(replaceLineEdit->text());
    textEdit->moveCursor(QTextCursor::StartOfWord);
    QTextCursor c = textEdit->textCursor();
    c.select(QTextCursor::WordUnderCursor);

       QTextCharFormat format = c.charFormat();
       format.setBackground(Qt::green); // this will set the background of word to green
       c.setCharFormat(format);
    
      }
    

    @
    I tried this to set some background color in order to highlight the replaced word. But after textEdit gains back focus the highlighted part should come to normal and that is not happening.. Now i need to restore the original background and I tried clearBackground() and it dint work for me..

    Plz help me with ur ideas.

    Thanks,
    Haney.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Please don't open multiple topics on the same issue. I have closed this topic. Discussion can continue in "your original topic":http://developer.qt.nokia.com/forums/viewthread/12040/ on the same issue.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved