Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How can I see the content of char readline[16] when debugging in QtCreator C++? [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

How can I see the content of char readline[16] when debugging in QtCreator C++? [SOLVED]

Scheduled Pinned Locked Moved Qt Creator and other tools
14 Posts 4 Posters 7.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vincegata
    wrote on last edited by
    #1

    Hello,

    I am running Qt Creator in Ubuntu, C++ project.

    I have a variable char readline [16]. When debugging how can I see the content of this variable? Locals and Expressions window shows the address of the first element, so does the Watch window.

    Thanks!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      GentooXativa
      wrote on last edited by
      #2

      Try this :P

      @
      #include <QDebug>
      qDebug() << readline[16];
      @

      Jose Vicente Giner Sanchez - Senior Mobile Developer

      www.gigigo.com

      C/ Dr. Zamenhof 36bis, 1ºA 28027 Madrid
      T: +34 917431436

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vincegata
        wrote on last edited by
        #3

        I can just use cout << readline; instead. I mean, how can I see it in a debugging window without entering any additional code? If I have a dozen of C-style strings I do not want to add some debugging code in every place those strings are used.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Thanatos.jsse
          wrote on last edited by
          #4

          I recommend you read the "documentation.":http://doc.qt.nokia.com/qtcreator-snapshot/creator-debug-mode.html#locals-and-expressions

          Qt Creator allow you interact with variables.

          BR,

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Just set a breakpoint at the line of interest. The "locals and expressions" tab of the debugger lists all variables in the current method, including the this pointer. Your readline variable should show up there. It also should have a + signe or a triangle the left, you can expand it and it shows you the contents of the array then. If you use a char * instead, it is treated as a string and the string is displayed directly.

            Find more infos about the debugger in the "respective section":http://doc.qt.nokia.com/qtcreator-2.4/creator-debugging.html of the "Qt Creator Manual":http://doc.qt.nokia.com/qtcreator-2.4/index.html.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vincegata
              wrote on last edited by
              #6

              If it was that easy I wouldn't be posting this question here :)

              In Locals and Expressions window I do have readline variable, it has a triangle, but if I click on it, it expands just nothing. I took a screenshot but I do not see how to post it here.

              [quote author="Volker" date="1327698555"]Just set a breakpoint at the line of interest. The "locals and expressions" tab of the debugger lists all variables in the current method, including the this pointer. Your readline variable should show up there. It also should have a + signe or a triangle the left, you can expand it and it shows you the contents of the array then. If you use a char * instead, it is treated as a string and the string is displayed directly.

              Find more infos about the debugger in the "respective section":http://doc.qt.nokia.com/qtcreator-2.4/creator-debugging.html of the "Qt Creator Manual":http://doc.qt.nokia.com/qtcreator-2.4/index.html.[/quote]

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                On DevNet, you cannot uplaod images directly. Just use a storage provider of your choice (dropbox, flickr, picasaweb, etc. are popular).

                In my case, if I just put a

                @
                char rl[16];
                @

                The debugger shows this (I'm using Creator 2.4 on a Mac):

                !http://qdn.berlinbikerx.de/Creator-Debugger-char-array.png!

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vincegata
                  wrote on last edited by
                  #8

                  I do not have that :(

                  What I have is:

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    The image is not protected, maybe some setting needs to be tweaked to make it public.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vincegata
                      wrote on last edited by
                      #10

                      Please check this one:

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        Hm, what makes me wonder is that the type is char[] in your screenshot, whereas in mine it's char[16]. How did you declare that variable?

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vincegata
                          wrote on last edited by
                          #12

                          ah, good catch. However it's still a bug if it's not resolvable through some sort of setting.

                          So, if I declare it the following way then I cannot see the content:
                          int MAXLINE = 1024;
                          char sendline[MAXLINE], recvline[MAXLINE];

                          It shows the variable if I declare:
                          char sendline [1024], recvline [1024];

                          Any ideas how to resolve it?

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #13

                            I'm not 100% sure here, but I would say that allocating a static array on the stack using dynamically calculated array size, i.e. putting a variable between the brackets, is not supported by all compilers. But that's a topic for the "C++ Gurus Forum":/forums/viewforum/36/

                            Regarding Qt Creator: I would guess that it's plain just not supported here. The code model would need to know the size of the array, but that is only calculated during runtime. Creator would have to evaluate the value of the MAXLINE variable and use that for the display of the array.

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              vincegata
                              wrote on last edited by
                              #14

                              Thank you for your help!

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved