Important: Please read the Qt Code of Conduct -

[SOLVED] Writing a new line in Qt5 is not working

  • I tried both << endl and << "\n" but it doesn't write me a new line. What's wrong with it?
    I intend to do it like this?


    but when I open the file they're just


    Please suggest me some tips for this. Thank you in advance

  • Moderators


    What class are you using to write the file?

    What OS are you writing the file in?

    What are you using to read the file?

    Linux uses '\n' but Windows uses '\r\n' for newlines. However, if you are using Qt's text writing classes, you just provide '\n' and Qt will convert it to '\r\n' for you automatically.

  • To what stream do you send it?
    Better show some code.

  • Unix base (Linux and OSX) OS's uses "\n" while Windows uses "\r\n"

  • Thank you all it works with ā€œ\r\nā€
    Thanks again it solved

Log in to reply