Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see Qt Source code while coding by Qt Creator?

Tags:

qt

qt-creator

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

like image 539
Behrouz.M Avatar asked Aug 03 '10 09:08

Behrouz.M


2 Answers

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 your project from scratch with the new settings. You should now be able to debug into Qt code.

like image 141
andref Avatar answered Sep 27 '22 18:09

andref


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...

like image 37
Tobias Hunger Avatar answered Sep 27 '22 19:09

Tobias Hunger