Nominate our 2022 Qt Champions!

QString \n \t not being translated

  • I'm not sure how I've managed to do this I'm building up a string that contains tabs (\t) and carriage returns (\n), however instead of tabs and carriage returns Im seeing the literal strings \t and \n in the Application Output. Is there any reason why this could be happening?

    Also, formatting this string:

    QString strMsg;
    strMsg = QString("S%1 ").arg(++msint64DbgSeqNo, 20, 10, QChar('0')) + strMsg;

    Gives an output something like:

    S00000000000000000016 "xmleng.setAttribute(strSID, \"title\", objJSON[\"text\"]); } } }*/"

    Where do the quotes come from after the 16 and at the end of the string?

  • That's how qDebug() normally prints QString.
    If you don't want it adding quotes and escaping non-printable characters, you should use qDebug().noquote()

  • @Bonnie Thank you, is there any way to change the default behaviour of qDebug to do this by default without having to edit every instance?

  • @SPlatten
    As far as I know, there's not.

  • Lifetime Qt Champion

    And there is no reason for it - it's debug output...

Log in to reply