Notepad does not display files properly unless they have the \r\n line ending. It has always done this. No other editor has this problem (including Wordpad).
When you open the file you can add the 'text' flag and Qt will convert to the proper line terminator for you based on the OS. If it sees '\n' in the file data to write it will automatically be converted to '\r\n'.
QFile file.open(QIODevice::WriteOnly | QIODevice::Text);
To copy to clipboard, switch view to plain text mode
Optionally you could use QString::replace() to do this as well. I should be wrapped with an #ifdef OS preprocessor and (very important) you must make sure your input data does not already have \r\n for line terminators (it will become \r\r\n after 'replace').
#ifdef Q_OS_WIN
text_data.replace('\n','\r\n');
#endif
#ifdef Q_OS_WIN
text_data.replace('\n','\r\n');
#endif
To copy to clipboard, switch view to plain text mode
.
Bookmarks