Isuue with /n in Qt Creator
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Isuue with /n in Qt Creator

  1. #1
    Join Date
    Jan 2013
    Posts
    44

    Isuue with /n in Qt Creator

    Hi everybody !

    I am using Qt Creator with VS2012 compiler.
    I declared a QByteArray variable : T
    I initialized it. Everything OK.
    I added the line :

    Code:
    T += "\n";
    What follows gives me an exception and I think that the issue comes from this added line. As I take a look at T in the debugger, I don't see any \n but a point .

    Could you explain please ?
    Many thanks.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,472

    Re: Isuue with /n in Qt Creator

    "\n" is not a byte but char array (more precisely: a pointer to the first element of the char array)
    So why do you add it to the QByteArray instance?
    Perhaps you wanted to do
    Code:
    T += '\n';
    Victor Nijegorodov

  3. #3
    Join Date
    Jan 2013
    Posts
    44

    Re: Isuue with /n in Qt Creator

    I mean LF that has ascii code 10.
    Why can't I see in the debugger window. It's displayed as a "."

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,472

    Re: Isuue with /n in Qt Creator

    How it is displayed depends on the debugger or/and IDE.
    How did you expect it to be displayed?
    Victor Nijegorodov

  5. #5
    Join Date
    Jan 2013
    Posts
    44

    Re: Isuue with /n in Qt Creator

    For example, I expected to see:

    T "On the air\n"

  6. #6
    Join Date
    Jan 2013
    Posts
    44

    Re: Isuue with /n in Qt Creator

    And I see :

    T "On the air."

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,472

    Re: Isuue with /n in Qt Creator

    Quote Originally Posted by mulfycrowh View Post
    For example, I expected to see:

    T "On the air\n"
    Hmm, I never saw any debugger showing LF as '\n'" in a debugger window.
    Note that LF (as well as CR, TAB and many others) are non-printable symbols! And displaying them as '\n' (or '\r', '\t') would confuse user because he/she would think there are two characters: backslash and 'n'!
    Victor Nijegorodov

  8. #8
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,557

    Re: Isuue with /n in Qt Creator

    lf, cr, tab etc are non-printable chars in the ASCII code set. These type of chars are shown as a '.' when trying to display text. If you want to see these non-printable chars then you will need to display in hex when lf will shown as 0a etc.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  9. #9
    Join Date
    Jan 2013
    Posts
    44

    Arrow Re: Isuue with /n in Qt Creator

    Ok but I have another computer running another software in Qt Creator. It displays the string as \n. So I don't understand. I looked for some settings in Qt Creator but I didn't find anything. Weird ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center