Skip to content

Commit 415dc3e

Browse files
authored
Setup guide
Since the page was bare bones, I tried to create a small setup guide.
1 parent 71b14e7 commit 415dc3e

1 file changed

Lines changed: 93 additions & 9 deletions

File tree

web/wiki/GDB-qtcreator.md

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,96 @@ summary: WAP.
44

55
# Qt Creator
66

7-
This page is extremely work-in-progress. Eventually it will cover setting up Qt Creator so you can "Start and Debug External Application ..." (you need to build it from source to get access to the latest patch that makes this workable), rebuilding and reinstalling the involved packages in debug, !strip mode and debugging them. The also being able to see Python callstacks and pretty printing of GDB internals in-case you are debugging those sorts of things. For now, this is all I have:
8-
9-
.. To see Python Callstacks and vars when debugging something that intermixes Python and C/C++ (e.g. pygtk)
10-
.. add to .gdbinit or QtCreator Tools->Options->Debugger->GDB->Additional Startup Commands, enter
11-
python
12-
sys.path.append('C:/msys64/mingw64/share/gdb/python3')
13-
import python-gdb
14-
reload(python-gdb)
15-
end
7+
This page is extremely work-in-progress. Eventually it will cover setting up Qt Creator so you can "Start and Debug External Application ..." (you need to build it from source to get access to the latest patch that makes this workable), rebuilding and reinstalling the involved packages in debug, !strip mode and debugging them.
8+
9+
---
10+
11+
# Qt Creator Setup with C++ (MSYS2 + UCRT64)
12+
13+
## 1. Installation
14+
15+
### Install the MSYS2 Toolchain
16+
1. Download and install [MSYS2](https://www.msys2.org/).
17+
2. In the MSYS2 terminal, install the UCRT64 toolchain:
18+
```bash
19+
pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
20+
```
21+
3. Add `C:\msys64\ucrt64\bin` to your Windows **PATH** environment variable.
22+
23+
### Install Qt Creator
24+
In the MSYS2 UCRT64 terminal:
25+
```bash
26+
pacman -S mingw-w64-ucrt-x86_64-qt6-base mingw-w64-ucrt-x86_64-qt-creator mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja
27+
```
28+
You can also disable clang by going through
29+
``Help > About Plugins > C++ > ClangCodeModel``
30+
and uncheck the "Load" box.
31+
32+
---
33+
34+
## 2. Configuration
35+
36+
Launch Qt Creator from the UCRT64 terminal:
37+
```bash
38+
qtcreator
39+
```
40+
> Or open from ``C:\msys64\ucrt64\bin\qtcreator.exe``.
41+
42+
Go to **Edit > Preferences** > **Kits**.
43+
44+
### Compilers
45+
- Click the **Compilers** tab.
46+
- Confirm `GCC (C++, x86 64bit)` from `C:\msys64\ucrt64\bin` is detected.
47+
- If missing: **Add > GCC > C++** and point to `g++.exe` in the bin folder.
48+
49+
### Kits
50+
- Go to the **Kits** tab and select **Desktop** (or create a new kit) and ensure the configurations are set.
51+
| | | |
52+
|---|---|---|
53+
| Compiler | GCC (C++) | C:\msys64\ucrt64\bin\g++.exe
54+
| Debugger | GNU gdb (ucrt64 bin) | C:\msys64\ucrt64\bin\gdb.exe
55+
| Qt Version | | C:\msys64\ucrt64\bin\qmake-qt6.exe
56+
| CMake Tool | | C:\msys64\ucrt64\bin\cmake.exe
57+
58+
---
59+
60+
## 3. "Hello World!"
61+
62+
- Open `mainwindow.ui` inside the Forms folder and drag a **Label** widget onto it or
63+
- Add the label on `mainwindow.cpp`:
64+
65+
```cpp
66+
#include "mainwindow.h"
67+
#include "ui_mainwindow.h"
68+
69+
MainWindow::MainWindow(QWidget *parent)
70+
: QMainWindow(parent)
71+
, ui(new Ui::MainWindow)
72+
{
73+
ui->setupUi(this);
74+
75+
QLabel *label = new QLabel("Hello World!", this);
76+
}
77+
78+
MainWindow::~MainWindow()
79+
{
80+
delete ui;
81+
}
82+
```
83+
84+
- You can now run the project using the green arrow left below.
85+
86+
You can also open the project from Qt Creator by running the CMakeLists.txt file:
87+
>File > Open File or Project > select CMakeLists.txt
88+
89+
90+
---
91+
92+
### Deploy as Standalone Executable
93+
94+
```bash
95+
cd path/to/your/project
96+
/c/msys64/ucrt64/bin/windeployqt6.exe qt-project.exe
97+
```
98+
99+
This adds all the dependencies next to your executable.

0 commit comments

Comments
 (0)