Skip to main content

History: Setting Up An Application - QtCreator

Source of version: 32 (current)

Copy to clipboard
            {DIV(class="Layout_box6")}{SPLIT(colsize=15%|85%)}{img fileId="1919"}---
{DIV(class="bigBold")}Setting Up An Application With QtCreator{DIV}{SPLIT}
{DIV}
%clear%
!Introduction
This set of instructions will walk you through setting up a QtCreator C++ project from scratch.

When you have finished this tutorial you will be able to compile a working Ogre Application and you will be ready to start the ((Basic Tutorials)).

{maketoc}

!Prerequisites
Get QtCreator from qt-project.org.
Get the [http://qt-project.org/downloads|stable version] that fits your setup.
!New Project
Click New Project in the start screen, and choose Other Project - Empty project.
{img fileId="1909"}

__Give it a name and a place:__
{img fileId="1910"}

__Add files:__ (__Tip:__ Move your cpp and h-files to inside the Qt project folder before you do this!) 
{img fileId="1911"}

__Files added:__
{img fileId="1907"}

__Options:__
{img fileId="1908"}

__Qt4 Settings:__ (__Tip:__ In Qt 5 this is called "Build & Run". If you have installed Visual Studio before you installed the Visual Studio Qt 5-version, all this should already be correct set up., so you do not have to do anything here.)
{img fileId="1912"}

__Edit project file:__
{img fileId="1913"}
{CODE(wrap="1", colors="qmake")}
TEMPLATE = app
TARGET = OgreQtProject

DEFINES -= UNICODE

CONFIG -= qt

unix {
    # You may need to change this include directory
    INCLUDEPATH += /usr/include/OGRE
    CONFIG += link_pkgconfig
    PKGCONFIG += OGRE
}
win32 {
    LIBS *= user32.lib
    LIBS += -L$(OGRE_HOME)\\boost\\lib
    release:LIBS += -L$(OGRE_HOME)\\lib\\release
    debug:LIBS += -L$(OGRE_HOME)\\lib\\debug
    INCLUDEPATH += $(OGRE_HOME)\\include
    INCLUDEPATH += $(OGRE_HOME)\\include\\OIS
    INCLUDEPATH += $(OGRE_HOME)\\include\\OGRE
    INCLUDEPATH += $(OGRE_HOME)\\boost
    # If you are using Ogre 1.9 also include the following line:
    # INCLUDEPATH += $(OGRE_HOME)\\include\\OGRE\\Overlay
}
debug {
    TARGET = $$join(TARGET,,,d)
    LIBS *= -lOgreMain_d -lOIS_d
    # If you are using Ogre 1.9 also include -lOgreOverlay_d, like this:
    # LIBS *= -lOgreMain_d -lOIS_d -lOgreOverlay_d
}
release {
    LIBS *= -lOgreMain -lOIS
    # If you are using Ogre 1.9 also include -lOgreOverlay, like this:
    # LIBS *= -lOgreMain -lOIS -lOgreOverlay
}
HEADERS += \
    TutorialApplication.h \
    BaseApplication.h

SOURCES += \
    TutorialApplication.cpp \
    BaseApplication.cpp
{CODE}

__Build All__:
{img fileId="1914"}

__Build Settings:__

__Note:__ In the Release configuration, go to 
"Build Steps -> qmake", press "Details" and add
{CODE(wrap="1", colors="qmake")}
"CONFIG-=debug" "CONFIG+=release"
{CODE}
to the "Additional arguments:"

Then to this:
{img fileId="1918"}

__Custom Process Step settings:__ - do this for both the Debug and Release configuration:
__Note:__ You can also use environment variables here, in %-signs. Like this:
{CODE(wrap="1", colors="qmake")}
C:\Windows\System32\cmd.exe
/c copy debug\OgreQtProjectd.exe %OGRE_HOME%\bin\debug
{CODE}
and you probably want to leave the Working directory to the defaul value of %{buildDir}.
{img fileId="1915"}

__Run Settings__ - must make one for debug, one for release:
{img fileId="1917"}

__New Run Configuration:__
__Note:__ You can also use environment variables here, in %-signs. Like this:
{CODE(wrap="1", colors="qmake")}
Executable: OgreQtProjectd.exe
Working directory: %OGRE_HOME%\bin\debug
{CODE}
{img fileId="1916"} 
!Tutorial Framework
Tutorial Framework:
{img fileId="1657" width="400" thumb="y" alt="" rel="box"}
Download the ((Ogre Wiki Tutorial Framework)) here:
{ATTACH(id="61", page="Ogre Wiki Tutorial Framework",icon="1")}{ATTACH}
!Project Configuration

{TRANSCLUDE(page="seebox")}
[http://blog.codeimproved.net/2009/12/qtcreator-tips-and-tricks/|QtCreator Tips and Tricks]
{TRANSCLUDE}