Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
posvaluk
Posts: 5
Registered: ‎03-06-2013
My Device: Z10
Accepted Solution

Pretty printing Qt containers while debugging in QNX Momentics IDE

Hi All,

 

I'm just wondering if anyone knows how to view Qt containers in a human readable way under debug?

So ie if I have QString str("hello")    under debug i wanna see "hello" as a value of str instead of bunch of pointers

 

Thanks,

Philip

Please use plain text.
Regular Contributor
robinhuang
Posts: 52
Registered: ‎02-08-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

try qDebug() << &str;

Please use plain text.
New Developer
posvaluk
Posts: 5
Registered: ‎03-06-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

Yeah, surely that works... but it's not what I asked for. in example if I use gdb 7 can use python based kde pretty printers to discover content of Qt containers such as QList.
But I cannot get it working with gdb from blackberry NDK
Please use plain text.
Developer
indy2718
Posts: 36
Registered: ‎01-16-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

[ Edited ]

Yes you can have the QNX Momentics IDE debugger show the string in the variable window neatly.

Instructions:

Window->preferences->C/C++->debug->GDB  and make sure "pretty printing" is enabled

Make a file called .gdbinit in your project root folder and put this in:


python
import sys
sys.path.insert(0, '.')
from qt4 import register_qt4_printers
register_qt4_printers (None)
end

Then copy the qt4.py file from: https://projects.kde.org/projects/extragear/kdevelop/kdevelop/repository/revisions/master/changes/de...

Put that file in the same working directory (the project directory).  Or you can put it somewhere else, and replace the "." in "sys.path.insert(0, '.')"  with the folder containing the qt4.py

 

Next time you run the debugger, it should show the QString.

If you have any problems (it doesn't work), you can check out the gdb trace console, and the gdb console (try: source .gdbinit)  to see any errors.

 

I have yet to do this with the dinkum STL.   I just started....  PM me if you want the instructions once I'm done...

 

p.s. Special thanks to the kdevelop team that made this python module.

 

edit: removed set print pretty line in .gdbinit.  set up properly by qnx ide.

 

Please use plain text.
New Developer
posvaluk
Posts: 5
Registered: ‎03-06-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

Works perfectly! Exactly what i was looking for.

 

Thanks a lot

Please use plain text.
Regular Contributor
robinhuang
Posts: 52
Registered: ‎02-08-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

great. Please send me intruction for dinkum STL too

Please use plain text.
Developer
indy2718
Posts: 36
Registered: ‎01-16-2013
My Device: Z10

Re: Pretty printing Qt containers while debugging in QNX Momentics IDE

I created a github repository for Dinkum/QNX/Blackberry STL printers described here:

http://supportforums.blackberry.com/t5/Native-Development/BB-STL-gdb-pretty-printers-on-github/td-p/...

Please use plain text.