Qt World Summit: Register Today!

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

  • 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))
    QTextCursor c = textEdit->textCursor();

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

    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.


  • 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.

Log in to reply