Carriage Return in QString
I have a QTextEdit that contains a carriage return.
I convert to QString :
Code:
Message = qMessage->toPlainText();
Then I am unable to remove the carriage return from the QString and replace it with a space character.
I tried :
- to split the string with regexp "\r"
- the stupid
Code:
for ( int i = 0; i < Message.size(); i++ )
if ( ( Message
[i
] == QChar(10) ) && ( Message
[i
+1] == QChar(13) ) ) { Message[i] = ' ';
Message[i+1] = ' ';
}
- Message.replace("\r"," ");
- Message.replace(QRegExp("\r"), " "); even with "0x0D"
All fails.
At the end of the modification I copy back my QString to a QTextEdit to display the result and the carriage return is still there. No way to remove it.
Re: Carriage Return in QString
Re: Carriage Return in QString
Of course it works, jacek is not expert but god.
Re: Carriage Return in QString
It may be worth detecting the sequence CR,LF as well.
Re: Carriage Return in QString
Code:
#ifdef linux
#endif
#ifdef WIN32
#endif
#ifdef __APPLE__
#endif
Re: Carriage Return in QString
Ehm, the thread is 4 (in letters four) years old! But anyway, whats the goal by defining myNewLine? On windows there might be also files which only use new line character. And QTextEdit transforms the different line breakings to "\n", so no need to distinguish.
Re: Carriage Return in QString
Line 5 has the characters the wrong way around also.
Re: Carriage Return in QString
Hi Lykurg.
Is it possible to dispose QtextEdti to do NOT the transormation from \r\n to \n?