I understand that QString::split should be used to get a QStringList from a multiline QString. But if I have a file and I don’t know if it comes from Mac, Windows or Unix, I’m not sure if QString.split("\n") would work well in all the cases. What is the best way to handle this situation?
I understand that QString::split should be used to get a QStringList from a multiline
Share
If it’s acceptable to remove blank lines, you can try:
This splits the string whenever any of the newline character (either line feed or carriage return) is found. Any consecutive line breaks (e.g.
\r\n\r\nor\n\n) will be considered multiple delimiters with empty parts between them, which will be skipped.