Home     

Published

- 4 min read

Coding c++ with QtCreator for UnrealEngine

img of Coding c++ with QtCreator for UnrealEngine

Handy IDE

Almost every experienced c++ developer has his(her) coding habit, and a handy IDE for his(her) quick daily development

Some kinds of IDE are complex software , they integrate multiple coding languages and lots of tools, they are bulky and slow

When we developing Unreal Engine games in c/c++ , we only focus on c/c++ , we only want machine’s resources to service c/c++ develop, nothing else, for unreal engine itself consume huge of memory and cpu , gpu resources when it working on big uproject…

Here the IDE that I just mean write code for c/c++ , I don’t involve compiling and debugging c/++ code , for compiling , unreal editor has LiveCoding, for debugging , maybe we still need stick to Visual studio on Windows platform, and Xcode on MacOS platform …\

What IDE we want for UE c++ should meet the following conditions :

  • Free
  • Lightweight
  • Quick launch
  • c/c++ specialist
  • Quick code Auto complete
  • Custom code block/snipt
  • Auto generate override functions
  • Peaceful cpu fan when coding
  • Keep hard disk clean(without generating lots of intermittent/caching/hidden files)

Why QtCreator

For c/c++ specialist IDE , there are several choices , including QtCreator, CodeBlock , Vs Code…

lots people like VS Code, but I don’t, I wanna introduce QtCreator, for Unreal Engine c/c++ developing, it’s enough , I think…

Setup .pro file for uproject

We gonna use legacy mode (qmake) to manage c/c++ project in qt-creator, rather than the newer cmake mode

1, create a empty text file with .pro file extension

All c/c++ code files will organise by .pro file, we drag and drop this file into qt-createor, it then setup a empty c/c++ project

Insert this template lines to .pro file:

.pro

   #TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

#
#
PRJNAMETOOT = YOURPROJECTNAME   # uppercased your project name
DEFINES += "YOURPROJECTNAME_API="
DEFINES += "YOURPROJECTNAME_API(...)="
#
DEFINES += "UCLASS()=YOURPROJECTNAME_API"
DEFINES += "UCLASS(...)=YOURPROJECTNAME_API"
#
# this is true during development with unreal-editor...

DEFINES += "WITH_EDITORONLY_DATA=1"

## this project only
 
INCLUDEPATH += ../Intermediate/Build/Win64/UnrealEditor/Inc/$$PRJNAMETOOT/UHT
INCLUDEPATH += $$PRJNAMETOOT/Public $$PRJNAMETOOT/Private
# we should follow UE project struct to include files, start from prj.Build.cs folder
#
#  The Thirdparty libs including paths
#
#
#
include(defs.pri)
include(inc.pri)
#
## this project only
# INCLUDEPATH += $$UESRCROOT/Runtime/Renderer/Private

HEADERS += ....  # header files here

SOURCES +=   .... # cpp files here

Full content please reference Here

The defs.pri and inc.pri is qt-creator format including files, they just including lots of c/c++ header searching paths and defined some unreal engine specials macro defines , the purpose adding this defines is because qt-creator don’t know about unreal engine’s macors, we haven’t enabled unreal engine intelligence modular and IWYU this features consume lots of memory and when index auto-complete list, it’s very slow, and make the cpu fan frantic…

defs.pri

   DEFINES += "UE_GAME=1"
DEFINES += "IS_PROGRAM=0"
....
....
DEFINES += "USERFEEDBACK_API="
DEFINES += "COLLECTIONMANAGER_API="
##
##
DEFINES += "LogTemp" "Warning"
DEFINES += "BlueprintType" "Blueprintable" "BlueprintPure" "BlueprintImplementableEvent"
DEFINES += "BlueprintAssignable" "BlueprintInternalUseOnly" "EditAnywhere" "EditDefaultsOnly"
DEFINES += "VisibleAnywhere" "BlueprintReadOnly"
##
##  Because this macro unfriend with QtCreater , so we redefined they to empty in this editor....
DEFINES += "checkf" "check" "checkAtCompileTime" "checkCode" "checkfSlow" "checkLockFreePointerList"
DEFINES += "checkName" "checkNoEntry" "checkNoRecursion" "checkNoReentry" "checkSlow" "checkStats"

Full content please reference here

inc.pri

   #
# modify this two folder location to fit your environment
#
UESRCROOT = "C:/UnrealEngine/Engine/Source"
WINKITSROOT = "C:/Program Files (x86)/Windows Kits/10"
#
INCLUDEPATH += $$WINKITSROOT/include/10.0.22621.0/ucrt
INCLUDEPATH += $$WINKITSROOT/include/10.0.22621.0/shared
INCLUDEPATH += $$WINKITSROOT/include/10.0.22621.0/um
INCLUDEPATH += $$WINKITSROOT/include/10.0.22621.0/winrt
INCLUDEPATH += "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/INCLUDE"
#  #           "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433"
#
#
INCLUDEPATH += $$UESRCROOT/Runtime/AdpcmAudioDecoder/Module/Public
...
....
INCLUDEPATH += $$UESRCROOT/Runtime/XmlParser/Public
##
INCLUDEPATH += $$UESRCROOT/Runtime/Engine/Classes
##
INCLUDEPATH += $$UESRCROOT/../Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Public
INCLUDEPATH += $$UESRCROOT/../Plugins/Runtime/ChunkDownloader/Source/Public
## online subsystem
INCLUDEPATH += $$UESRCROOT/../Plugins/Online/OnlineSubsystem/Source/Public
INCLUDEPATH += $$UESRCROOT/../Plugins/Online/OnlineServices/Source/OnlineServicesInterface/Public

##  Any other herder seraching paths append here
##
#

Full content please reference Here

Custom c++ code block(snipt) in qt-creator

Finalize

After correctly setting .pro file for qt-creator, we can now write c/c++ for unreal engine project.

  • we need to manually include all relevance header files at the top of the cpp files (yes ,this step is annoying , but this is the key for save memory)
  • in oder to let qt-crteaor’s auto-complete works correctly , we need to append all header files searching paths, instead of other IDE auto scan them for you(they found thousands of header files , parse them and put the result into memory, but we don’t want IDE do that )
  • Qt-creator still can’t recognise some unreal engine specialist macro, such as UCLAA(…) , GENERATE_CLASS_BODY(), and so on…it’s sometimes annoying~
  • When we need to compile the code just written , we just call unreal engine’s LiveCodeing by pressing ALT+CTRL+F11 , it’s a system shortcut, we can call it anywhere any time, then our code will be compile and read for debugging …

Happy coding

I just wrote something I knew about qt-creator for c/c++ coding, I hope I can manage more c/c++ technical and do good at Unreal Engine Game Development …

thanks for reading!

Related Posts

There are no related posts yet. 😢

Support this blog

    I'm trying my best to share knowledge about Unreal Engine Game developing. If you think these posts have either helped or inspired you, please consider supporting this blog. Thank you so much for your contribution!
Ko-fi Me
Paypal Me