views:

82

answers:

2

How to see Qt Source code while coding by Qt Creator ? when I Debug my program and hit a break point, and when I press F11 over a Qt function , Debugger steps into source code of that function, it is very interesting stuff :D now, I will see the source code of Qt functions in Qt creator while coding , not at Debug time :D

+3  A: 

You need a debug build of Qt, and you have to build it yourself. Building Qt is easy: see the Installation part of the documentation.

Adding the debug version to Qt Creator

The following instructions are for Qt Creator 2.0.0. If you're using a different version, adapt as needed. First, you need to add your debug build to the list of available Qt Versions.

  1. Select the Tools > Options menu;
  2. Pick the Qt4 page;
  3. Click the + button;
  4. Click the Browse button and select the qmake binary that is inside the bin directory of your custom-built Qt;
  5. Click Rebuild to build the debugging helpers. This is important!
  6. Click OK.

Now, configure the project to use your debug build during compilation.

  1. Back in the Qt Creator main window, select the Projects view;
  2. Pick the tab corresponding to your project;
  3. Select Build Settings;
  4. On General, change the Qt Version to the version you added on the previous part.

Rebuild of your project from zero with the new settings. You should now be able to debug into Qt code.

andref
I have built Qt source code. Now please tell me what do I have to do ?
Behrouz Mohamadi
See the edited answer.
andref
+1  A: 

F2 is "follow symbol under cursor". That should get you to the right place, independently of whether the code was provided by some included header file or not.

Your own projects will most likely not include the Qt source files though, so you can not jump into them directly (they are not referenced from the project, so they are not there for creator). So during editing you will not be able to just jump straight into the Qt source code. Debugging will of course work (see previous answer, buit rebuilding your own Qt shouldn't actually be necessary).

You can open the projects.pro file found in the Qt sources as an additional project in creator. Then you can at least use the locator (Ctrl-K) to look up methods, etc.

Hope this helps...

Tobias Hunger