'Writing Strings in multiple lines using Qstring

I'm trying to create a string which must output info in several lines. Earlier I was using Qt4 and QString( "\n" ) was perfectly working, but as I migrated to qt5, the output won't be written in multiple lines but instead the "\n" will be added to the beginning of each output expression. This is how the output looks like:

tempString = "\nC 1 Guidance \nC 2 LINE AREA MAP ID \nC 3 YEAR OBSERV \nC 5 RECORD AUXILIARY RECORD CDF FOLD \nC 6 SAMPLE INTERVAL SAMPLES/TRACE BITS/IN BYTES/SAMPLE \nC 7 RECORDING FORMAT FORMAT THIS REEL MEASUREMENT SYSTEM \nC 8 SAMPLE: FLOATING PT FIXED PT FIXED PT-GAIN CORRELATED \nC 9 FIXED

The output using qt4 was:

tempString = " \nC 1 Guidance
\nC 2 LINE AREA MAP ID \nC 3 YEAR OBSERV
\nC 5 RECORD AUXILIARY RECORD CDF FOLD
\nC 6 SAMPLE INTERVAL SAMPLES/TRACE BITS/IN
\nC 7 RECORDING FORMAT FORMAT THIS REEL MEASUREMENT
\nC 8 SAMPLE: FLOATING PT FIXED PT FIXED PT-GAIN
\nC 9 FIXED

Here is the part of my code which creates the string:

QString tempString = QString( "\n" );
                QDataStream readFile( &recordFile );
                readFile.setByteOrder( config->getISDataByteOrder() );
                readFile.setVersion( QDataStream::Qt_5_5 );
                for ( int i = 0; i < 40; i++ ) {
                    for ( int j = 0; j < 80; j++ ) {
                        readFile >> temp->textualHeader[ i ][ j ];
                    }
                }
                
                temp->convertTextualHeader( true );
                for ( int i = 0; i < 40; i++ ) {
                    for ( int j = 0; j < 80; j++ ) {
                        //qDebug() << "temp->textualHeader[" << i << "][" << j << "] =" << temp->textualHeader[ i ][ j ] << ";";
                        tempString += QString( temp->textualHeader[ i ][ j ] );
                    }
                    tempString += QString( "\n" );
                }
                qDebug() << "tempString =" << tempString << ";";

Does anybody has an idea why QString( "\n" ) doesn't create new lines in this case?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source