Results 1 to 7 of 7

Thread: How to View QString Object data while debugging?

  1. #1
    Join Date
    Feb 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default How to View QString Object data while debugging?

    Hi,

    While debugging its not possible to view the QString object data in Locals & Watchers in QtCreator.Its showing blank.Only int and addresses are shown under the Value section.

    Plz any one share ur ideas if u know?


    Regards,
    Payal

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to View QString Object data while debugging?

    hi payal
    u can use qDebug() to know the values at runtime

    ex

    Qt Code:
    1. QString str="welcome";
    2. qDebug()<<str;
    To copy to clipboard, switch view to plain text mode 

    see the result in Application Output [alt+3]
    hope it helps
    Bala

  3. #3
    Join Date
    Feb 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to View QString Object data while debugging?

    i tried using as per your code,i am getting following errors.

    1.error: invalid use of incomplete type ‘struct QDebug’
    2./usr/include/qt4/QtCore/qglobal.h:1467: error: forward declaration of ‘struct QDebug’

    Any idea how to resolve this?
    Last edited by payal; 24th February 2010 at 07:31.

  4. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to View QString Object data while debugging?

    hi,
    have u included <QtGui> ?

    if QtGui included then QDebug will work

    if not include <QDebug>

    hope it helps
    Bala

  5. #5
    Join Date
    Feb 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to View QString Object data while debugging?

    Thanks alot,it got solved by including <QtGui>

    I was tring with <qDebug>

  6. #6
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to View QString Object data while debugging?

    It will work with <QDebug> not <qDebug>

    anyway , if u include <QtGui> there is no need to include <QDebug>

    Bala

  7. #7
    Join Date
    Feb 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default View QT Objects while debugging! Re: How to View QString Object data while debugging?

    View QT Objects While Debugging
    See your QStrings without drilling down!

    (quick view in bold)

    The kde-devel-gdb package has a bunch of gdb command definitions to help with viewing QString as well as other structures in gdb. You can also use this from within Eclipse via the gdb terminal.

    First of all, you need to get the commands loaded into gdb.

    get the gdb commands file ( I'll paste the current version on the end here) from kde-devel-gdb.
    modify your ~/.gdbinit file to reference it by adding this line at the end:
    source ~/kde-devel-gdb


    now run gdb in a terminal and type:
    apropos q4
    and you should see a number of the new commands appear ( such as printq4string )
    use the 'q' command to quit

    Now run Eclipse

    Within Eclipse, go to the Run->DebugConfigurations... Debugger tab and set the GDB command file to your .gdbinit . It may look right... browse to and choose it again anyways.

    start debugging something and get to a breakpoint preferably near a QString.

    Note that if you select the gdb process in the debug window that the console will switch to gdb.
    That changes the context however and you can't get to your variables.

    instead, select a thread in the debug window that gets you back to your variable list and then on the upper right of the console window select the little computer monitor drop down and choose gdb.

    try apropos q4 again in this gdb console... verify that the printq4string command is there. If not then see the line above just after 'Run Eclipse'. You can also manually run 'source ~/kde-devel-gdb'

    now, in the gdb console try to get a QString to print..
    printq4string your_QString_here

    success!


    problems still?:
    my gdbinit's 3rd line wasn't liked by gdb and I had to comment it out. watch for complaints when you run gdb from a terminal.
    note.. it's printq4string NOT printqt4string.. no 'T'! I'm changing mine to pq or something short instead anyways.


    If you figure out a way to automate this further in the eclipse debugger ( use a gdb command in a watch?? debug view casting? ) please tell the rest of us!
    (I'm at least changing to a shortened command name.. )


    Attachment 5950
    I'll attach the kde-devel-gdb file from: http://websvn.kde.org/trunk/KDE/kdes.../kde-devel-gdb . Fewb 14, 2011 version.
    Attached Files Attached Files

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 21:09
  2. QString and debugging
    By bnilsson in forum Qt Programming
    Replies: 4
    Last Post: 15th February 2011, 06:38
  3. Eclipse debugging: Unable to create variable object
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 22:42
  4. Replies: 2
    Last Post: 27th April 2009, 16:15
  5. How can I read binary data to QString?
    By zolookas in forum Newbie
    Replies: 2
    Last Post: 29th July 2008, 21:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.