views:

346

answers:

2

I just installed QT 4.6 on snow leopard 10.6.3. I wrote a really simple program. I can generate a xcode project using qmake, but I can't step into QT function. How can I set it up?

A: 

I haven't tried this on Mac, but on Linux you need to take the following process:

First, you need to setup Qt so that it has debugging symbols available to you:

./configure -debug-and-release separate-debug-info # other options

With the debugging symbols available, you should now be able to get valid stack traces.

When building your application with qmake, you need to have the debug (or debug_and_release) flag set in your project file:

CONFIG += debug

Once you've done that, you should only need to tell the debugger where the Qt source is located:

(gdb) dir /path/to/qt/src

After that, list should show you the actual Qt source code. You may need to add additional directories under the src directory for the debugger to pick it all up.

Kaleb Pederson
A: 

By default, qt is built with a debug and a non-debug library. This is my understanding. For example,

% ls /Library/Frameworks/QtCore.framework/
Contents/           Headers@            QtCore@             QtCore.prl          QtCore_debug@       QtCore_debug.dSYM/  QtCore_debug.prl    Versions/

Also, my default from source build of Qt 4.7 branch also has the *_debug libs.

Setting up for Xcode is cake, you just set up your project and

% qmake -spec macx-xcode

This -spec is the default for the official mac distribution, but if you build your own from source the default is macx-g++ which creates a Makefile project.

This generates a MyProject.xcodeproj that comes preconfigured to link all the necessary Qt frameworks, sets up paths, and has a Release and Debug build target set to the same options as the official SDK's.

This is all assuming you have your qt project file set up, if you need to generate that first from a raw source directory:

% qmake -project

Debugging works "out of the box" for these generated *.xcodeproj files. However, there's one little "hitch". Since Qt is full of custom data types, Xcode doesn't know how to display their "values" in the debugger's summary pane. So you can't see what value a QString has, for example.

There's a method of entering custom macros for display, but I've found these often (always?) don't work for QObjects.

To get that working, I've started a project that uses xcode's debugger c callbacks (also mentioned in the above linked article, though their example doesn't even work o.O). I call it Qt4DataFormatters.

I've just started it and have been adding types as the need arises. It's dirt simple to create one using the existing functions as a template though.

jkyle