Try replacing all the "\n" with QString(QChar('\n'))

i.e. use

replace("\\n",QString(QChar('\n')));

I am not sure if this will work or not.