PDA

View Full Version : QTextBrowser Problem



Cutey
17th January 2007, 15:18
Hi,

In my application, I have a problem with find a word in the QTextBrowser.

For some texts,
It finds occurrence of the text in the whole document when it reached end of document, it reports "Text not found" rather than "Search reached end of the document".

At the same time if the user presses the "FIND" subsequently, find process goes one step backwardly to the document and then proceed from the starting of the document.

Note:
The above problem is not for all the text in the document.

This is my Code snippet:

bool DWCHelpWindow::findTextInWindow ( const QString& searchStr, QString& resultStr, bool cs, bool wo, bool forward ) {
if ( !bIsLimitReached ) {
if ( m_browser->find ( searchStr, cs, wo, forward ) ) {//m_browser is member of QTextBrowser
resultStr = "";
bIsLimitReached = FALSE;
return TRUE;
} else {
if ( m_browser->find ( searchStr, cs, wo, ( !forward ) ) ) {
if ( !bIsLimitReached ) {
if ( forward ) {
m_browser->find ( searchStr, cs, wo, ( forward ) );
resultStr = "Search reached end of the document";
} else {
m_browser->find ( searchStr, cs, wo, ( forward ) );
resultStr = "Search reached start of the document";
}
}
bIsLimitReached = TRUE;
} else {
resultStr = "Text not found";
}
return FALSE;
}
} else
return FALSE;
}I could not figure out the problem.
plz any help.

wysota
19th January 2007, 11:19
What is the actual problem? From what I see it looks like you search backwards in some other way than when you search forwards. When you set bIsLimitReached to true, it stays true which implies that the inner branch (if(!bIsLimitReached)) is never entered when searching backwards.