Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Qt Creator

Qt Creator 是免費、開放原始碼,支援所有桌面平台的 IDE。

匯入專案

  • 在 Qt Creator 主畫面選擇 New Project > Import Project > Import Existing Project。

../../../_images/qtcreator-new-project.png
  • 於 Location 選擇 Godot 根目錄。

../../../_images/qtcreator-set-project-path.png
  • 接下來你可以選擇要讓哪些資料夾與檔案在專案中可見。C/C++ 檔案會自動加入,也可考慮加入其它副檔名如:著色器檔案 *.glsl、建置系統 *.py、Android 平台用 *.java、macOS 平台用 *.mm 等。

../../../_images/qtcreator-apply-import-filter.png

備註

日後可在專案上點右鍵,選擇 Edit Files... 來調整這些設定。

../../../_images/qtcreator-edit-files-menu.png
  • 完成匯入。

  • 打開 project_name.includes 檔案,加入一行 . 以正確啟用程式碼補全。

../../../_images/qtcreator-project-name-includes.png
  • 於左側選單選擇 Projects,並切到 Build 分頁。

  • 刪除預設的 make 建置步驟。

../../../_images/qtcreator-projects-build.png
  • 點擊 Add Build Step > Custom Process Step 新增建置步驟,內容如下:

    命令

    scons

    參數

    所有可用參數請見 建置系統介紹。

../../../_images/qtcreator-set-scons-command.webp

備註

如果出現 Could not start process "scons" 等錯誤,代表 scons 沒有在你的 PATH 環境變數中,請填入 SCons 執行檔的完整路徑。

除錯專案

  • 於左側選單選擇 Projects,切到 Run 分頁。

  • Under Executable specify the path to your executable located in the <Godot root directory>/bin folder. The name depends on your build configuration, e.g. godot.linuxbsd.editor.dev.x86_64 for 64-bit LinuxBSD platform with platform=editor and dev_build=yes. You can use %{buildDir} to reference the project root, e.g., %{buildDir}/bin/godot.linuxbsd.editor.dev.x86_64.

  • 若要執行特定 Godot 專案,請在 Working directory 指定該專案資料夾。

  • 若想啟動 Godot 編輯器,請在 Command line arguments 加入 -e。

../../../_images/qtcreator-run-command.png

更多命令列參數資訊請參考 命令列教學。

程式碼風格設定

Developers must follow the project's code style and the IDE should help them follow it.

  • Open Preferences > C++ > Code Style.

  • Set the Formatting mode to Full formatting to instruct Qt Creator to use the .clang-format file supplied in Godot's root folder:

../../../_images/qtcreator-options-cpp.webp
  • Specify when you want clang-format to run (either while typing or when you saving the file). It is recommended to enable formatting on save at least.

如遇問題,歡迎到 Godot 社群頻道 求助。