View Full Version : Find and line endings

17th October 2006, 14:10
I am using Qt4.1.4 and writing a simple source text editor based on QTextEdit (actually converting a Qt3 working application but the query is new).

I have noticed that the text string of a selection spanning a line ending contains a two-byte unicode (0x02920?) where the line break occurs. When this is used in a QTextDocument find the search fails to find identical text spanning a line break or indeed text with the line break code omitted, i.e. any search string of this nature is bound to fail.

Could someone enlighten me as to the policy here. I know it is unusual for editors to offer this capability, Microsoft's Visual Studio doesn't even allow the line break to get into the search string, but I think it could be quite useful. Now that Qt4's QTextEdit uses block objects to hold lines (paragraphs), dealing with line breaks must already be a bit more complicated than simply coping with 'LF' codes. Could we either prevent special codes getting into text strings, implement code to handle them or flag an error?

I hope this a new query - difficult to search on it - and thanks in advance for any comments.

22nd October 2006, 11:16
I suppose you would have to write your own find function. QTextDocument::find() iterates through appropriate blocks and performs the search on every block, one by one. Therefore a string covering multiple blocks is not found.