PDA

View Full Version : Finding text on Text edit



jyoti kumar
18th May 2006, 12:22
Created one QTextEdit widget named inputPane
Displaying text using syntax
m_uiMainWindow.inputPane->append(QString(designFile.readAll()));

Now I want to Find expr in the file displayed on input pane & highlight the same, but I am not able to do so.

Pls help.
I have used
if(m_uiMainWindow.inputPane->find(expr))
{
QMessageBox::information(this,tr("Find"),tr("Found"));
}
I am able to see "Found" message but I am not clear with what is to be done to highlight the found text.

gael.deest
18th May 2006, 13:17
Perhaps could you use a QSyntaxHilighter ? Looks ugly though.

gael.deest
18th May 2006, 13:20
From the Qt Assistant: "QTextEdit::find(...): Returns true if exp was found and changes the cursor to select the match". So your text should already be selected. If it isn't, it looks like a Qt bug to me.