CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  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
    Hanover Germany
    Posts
    20,396

    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
    Hanover Germany
    Posts
    20,396

    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
    Hanover Germany
    Posts
    20,396

    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
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  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
  •  





Click Here to Expand Forum to Full Width

Featured