Get Involved/development/IDE configuration/Qt Creator: Difference between revisions
m (Add screen recording) |
(Two chapters) |
||
Line 3: | Line 3: | ||
A screen recording version is available https://www.youtube.com/watch?v=ASnDeEaXnbI | A screen recording version is available https://www.youtube.com/watch?v=ASnDeEaXnbI | ||
== | ==kdesrc-build== | ||
After you configure kdesrc-build and you can correctly build a KDE | After you configure kdesrc-build and you can correctly build a KDE project such as kcalc. | ||
Edit ~/.config/kdesrc-buildrc . It should look like: | Edit ~/.config/kdesrc-buildrc . It should look like: | ||
Line 21: | Line 21: | ||
... | ... | ||
cmake-options -DCMAKE_BUILD_TYPE=Debug | cmake-options -DCMAKE_BUILD_TYPE=Debug | ||
... | |||
stop-on-failure false | |||
... | |||
directory-layout invent | |||
</nowiki>}} | </nowiki>}} | ||
Line 32: | Line 36: | ||
</nowiki>}} | </nowiki>}} | ||
E.g. | ==Qt Creator== | ||
Install Qt Creator. E.g. download from Qt the latest version. Or e.g. from your current Linux distribution's packages. E.g. | |||
{{Input|1=<nowiki> | {{Input|1=<nowiki> | ||
apt install qtcreator | apt install qtcreator | ||
Line 44: | Line 50: | ||
From the qtcreator main menu | From the qtcreator main menu | ||
> File > Close | > File > Close All Projects and Editors | ||
> File > Open File or Project <code>~/kde/src/utilities/kcalc/CMakeLists.txt</code> | |||
Left Sidebar > Switch to Projects mode Ctrl+5 > Manage Kits... Under Manual, keep only "Desktop (default)". E.g. select Manual > Qt 5.15.4 (qt5) > Remove button > OK. | |||
Button "Import Existing Build..." > Directory: ~/kde/build/utilities/kcalc > Choose. | |||
Everything should be configured correctly. | |||
Left Sidebar > Switch to Projects mode Ctrl+5 > Active project: kcalc. Build & Run: not the Desktop kit. Build Settings > build configuration: "Debug2". | |||
Click on the left sidebar, the button above "Run Ctrl+R". It should show: Project: kcalc. Kit: not the Desktop kit. Deploy: Deploy Configuration. Build: Debug2. Run: kcalc. | |||
Left Sidebar > Switch to Edit mode (Ctrl+2) > Select "Projects" from the combobox. In the "Projects" left hand treeview > kcalc > kcalc > Source Files > double click on the file kcalc.cpp. The file kcalc.cpp will be shown in the editor view. Click inside the source code in text editor. | |||
In the text editor's top bar > function/identifier/method/type/symbols combobox, select the last item: <code>main(int, char***) -> int</code>. Click on the line with the opening curly bracket of the function main. From the main menu > Debug > Set or Remove Breakpoint (F9). | |||
Left Sidebar > Start debugging of startup project. The debugger will start correctly and break on the source code line with the curly bracket. | |||
From the main menu Debug > Step Over (F10)/Step Into(F11)/Step Out (Shift+F11). | |||
Revision as of 19:37, 31 July 2022
Qt Creator is an IDE from Qt.
A screen recording version is available https://www.youtube.com/watch?v=ASnDeEaXnbI
kdesrc-build
After you configure kdesrc-build and you can correctly build a KDE project such as kcalc.
Edit ~/.config/kdesrc-buildrc . It should look like:
global ... include-dependencies true ... kdedir ~/kde/usr ... source-dir ~/kde/src ... build-dir ~/kde/build ... cmake-options -DCMAKE_BUILD_TYPE=Debug ... stop-on-failure false ... directory-layout invent
The line above is important in order to use the debugger from Qt Creator.
Make sure you have the correct number on the line num-cores
.
Build kcalc, make sure there are no errors:
kdesrc-build --include-dependencies kcalc
Qt Creator
Install Qt Creator. E.g. download from Qt the latest version. Or e.g. from your current Linux distribution's packages. E.g.
apt install qtcreator
Start Qt Creator. E.g. from a terminal
qtcreator &
From the qtcreator main menu
> File > Close All Projects and Editors
> File > Open File or Project ~/kde/src/utilities/kcalc/CMakeLists.txt
Left Sidebar > Switch to Projects mode Ctrl+5 > Manage Kits... Under Manual, keep only "Desktop (default)". E.g. select Manual > Qt 5.15.4 (qt5) > Remove button > OK.
Button "Import Existing Build..." > Directory: ~/kde/build/utilities/kcalc > Choose.
Everything should be configured correctly.
Left Sidebar > Switch to Projects mode Ctrl+5 > Active project: kcalc. Build & Run: not the Desktop kit. Build Settings > build configuration: "Debug2".
Click on the left sidebar, the button above "Run Ctrl+R". It should show: Project: kcalc. Kit: not the Desktop kit. Deploy: Deploy Configuration. Build: Debug2. Run: kcalc.
Left Sidebar > Switch to Edit mode (Ctrl+2) > Select "Projects" from the combobox. In the "Projects" left hand treeview > kcalc > kcalc > Source Files > double click on the file kcalc.cpp. The file kcalc.cpp will be shown in the editor view. Click inside the source code in text editor.
In the text editor's top bar > function/identifier/method/type/symbols combobox, select the last item: main(int, char***) -> int
. Click on the line with the opening curly bracket of the function main. From the main menu > Debug > Set or Remove Breakpoint (F9).
Left Sidebar > Start debugging of startup project. The debugger will start correctly and break on the source code line with the curly bracket.
From the main menu Debug > Step Over (F10)/Step Into(F11)/Step Out (Shift+F11).