OLD | NEW |
---|---|
(Empty) | |
1 # Use Qt Creator as IDE or GUI Debugger | |
2 | |
3 [Qt Creator](https://www.qt.io/ide/) | |
4 ([Wiki](https://en.wikipedia.org/wiki/Qt_Creator)) is a cross-platform C++ IDE. | |
5 | |
6 [TOC] | |
7 | |
8 ## Workflow | |
9 | |
10 1. `ctrl+k` Activate Locator, you can open file(not support sublime-like-search) or type `. ` go to symbol. | |
11 2. `ctrl+r` Build and Run, `F5` Debug. | |
12 3. `F4` switch between header file and cpp file. | |
13 4. `ctrl+shift+r` rename symbol under cursor. | |
14 5. Code completion is built-in. And you can add your snippets. | |
15 | |
16 ## Setup as IDE | |
17 | |
18 1. Install latest Qt Creator | |
19 2. under chromium/src `gn gen out/Default --ide=qtcreator` | |
20 3. qtcreator out/Default/qtcreator_project/all.creator | |
21 | |
22 It takes 3 minutes to parsing C++ files in my workstation!!! And It will not | |
23 block you while parsing. | |
Primiano Tucci (use gerrit)
2017/02/09 13:45:56
I would probably mention that you can use Qt just
| |
24 | |
25 ### Code Style | |
26 | |
27 1. Help - About Plugins enable Beautifier. | |
28 2. Tools - Options - Beautifier - Clang Format, select use predefined style: | |
29 chromium. You can also set a keyboard shortcut for it. | |
30 3. Tools - Options - Code Style import this xml file | |
31 | |
32 ``` | |
33 <?xml version="1.0" encoding="UTF-8"?> | |
34 <!DOCTYPE QtCreatorCodeStyle> | |
35 <!-- Written by QtCreator 4.2.1, 2017-02-08T19:07:34. --> | |
36 <qtcreator> | |
37 <data> | |
38 <variable>CodeStyleData</variable> | |
39 <valuemap type="QVariantMap"> | |
40 <value type="bool" key="AlignAssignments">true</value> | |
41 <value type="bool" key="AutoSpacesForTabs">false</value> | |
42 <value type="bool" key="BindStarToIdentifier">false</value> | |
43 <value type="bool" key="BindStarToLeftSpecifier">false</value> | |
44 <value type="bool" key="BindStarToRightSpecifier">false</value> | |
45 <value type="bool" key="BindStarToTypeName">true</value> | |
46 <value type="bool" | |
47 key="ExtraPaddingForConditionsIfConfusingAlign">true</value> | |
48 <value type="bool" key="IndentAccessSpecifiers">true</value> | |
49 <value type="bool" key="IndentBlockBody">true</value> | |
50 <value type="bool" key="IndentBlockBraces">false</value> | |
51 <value type="bool" key="IndentBlocksRelativeToSwitchLabels">false</value> | |
52 <value type="bool" key="IndentClassBraces">false</value> | |
53 <value type="bool" key="IndentControlFlowRelativeToSwitchLabels">true</value> | |
54 <value type="bool" | |
55 key="IndentDeclarationsRelativeToAccessSpecifiers">false</value> | |
56 <value type="bool" key="IndentEnumBraces">false</value> | |
57 <value type="bool" key="IndentFunctionBody">true</value> | |
58 <value type="bool" key="IndentFunctionBraces">false</value> | |
59 <value type="bool" key="IndentNamespaceBody">false</value> | |
60 <value type="bool" key="IndentNamespaceBraces">false</value> | |
61 <value type="int" key="IndentSize">2</value> | |
62 <value type="bool" key="IndentStatementsRelativeToSwitchLabels">true</value> | |
63 <value type="bool" key="IndentSwitchLabels">false</value> | |
64 <value type="int" key="PaddingMode">2</value> | |
65 <value type="bool" key="ShortGetterName">true</value> | |
66 <value type="bool" key="SpacesForTabs">true</value> | |
67 <value type="int" key="TabSize">2</value> | |
68 </valuemap> | |
69 </data> | |
70 <data> | |
71 <variable>DisplayName</variable> | |
72 <value type="QString">chrome</value> | |
73 </data> | |
74 </qtcreator> | |
75 ``` | |
76 | |
77 ### Build & Run | |
78 | |
79 In left panel, projects - setup the ninja command in build and clean step and | |
80 executable chrome path in run. | |
81 | |
82 ## Setup Debugger | |
83 | |
84 You can skip the project settings and use QtCreator as a single file standalone | |
85 GDB frontend. | |
86 | |
87 1. Tools - Options - Build & Run - Debuggers, make sure GDB is set. | |
88 2. Tools - Options - Kits, change the Desktop kit to GDB(LLDB doesnot work in | |
89 Linux). | |
90 3. Open file you want to debug. | |
91 4. Debug - Start Debugging - Attach to running Application, you may need to | |
92 open chrome's task manager to find the process number. | |
93 | |
94 ### Tips, tricks, and troubleshooting | |
95 | |
96 #### Make GDB start fast | |
97 | |
98 Add `gdb_index = true` to `gn args`. | |
99 | |
100 #### Debugger shows start then finish | |
101 | |
102 ``` | |
103 $ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | |
104 ``` | |
105 | |
106 #### Debugger do not stop in break point | |
107 | |
108 Ensure you are using GDB not LLDB in Linux. | |
109 | |
110 #### Chrome Flags | |
111 | |
112 ``` | |
113 --no-sandbox ----render-startup-dialog --single-process | |
Primiano Tucci (use gerrit)
2017/02/09 13:45:56
single-process should not be required. is actually
| |
114 ``` | |
OLD | NEW |