HowTo Use OpenFOAM with QtCreator

From OpenFOAMWiki
Revision as of 18:24, 31 August 2012 by Rudolf.hellmuth (Talk | contribs)

Qt Creator is a powerful and flexible cross-platform integrated development environment (IDE) with strong orientation and support for C/C++ native development.

1 Why to use Qt Creator?

  • Open Source
  • Cross Platform – Works perfectly on Linux, Windows and Mac OS X
  • Direct compatibility with other applications of Qt SDK (great for building GUI-applications!)
  • Actively developed and improved
  • Excellent syntax highlighting
  • Magnificent code browsing and navigation in combination with useful and customizable keyboard shortcuts
  • Great and generic (works with any file you include, it doesn’t have to know anything special about it)
  • Code completion support
  • Easily customizable and Extensible through plugins
  • Support for integration with various Source Control Management tools like Git, Subversion, Bazaar, Mercurial, CVS and more.
  • Debugger integration with both GDB and Microsoft’s Debugging Tools for Windows through CDB
  • Custom configure, build, clean and deployment steps
  • Integration with tools like Valgrind
  • Per project settings
  • Vim editing mode
  • Code snippets
  • A pretty fast IDE, even when indexing hundreds of files with hundreds of thousands lines of code for the first time
  • Linux Man Pages context help integration - thanks to the flexible Qt Help System, this can be extended to almost any API

2 Download and installation

Most of the main Linux distributions have binaries in their repositories. Otherwise, download and install Qt Creator from http://qt.nokia.com/downloads.

Installation example in Debian/Ubuntu:

# apt-get install qtcreator

3 OpenFOAM project in Qt Creator

Obs.: Using Qt Creator version 2.5.0

3.1 Starting a project

  1. Open Qt Creator.
  2. Go to File \to New File or Project \to Other Project.
  3. Click on Import Existing Project.
    Import existing project
  4. Give your project a name and select the location to your project source tree. Select the directory where the source-files (*.C, *.H) of your OpenFOAM application are. A project-file <project name>.creator will be created inside the selected directory.
    Give a name and directory location
  5. A screen will pop up asking you to select the files to be added to the project.
    Selection of files for the project
  6. The next screen, Project Management, is going to ask you if you want to use source control management (git, svn) for your project and if yes,then the project files will be the first to be added to the project. You should add these files to the scm repository only if you know that they would be usefull for others, otherwise you should keep them to your self, by using exclude directives like .gitignore files in git or svn:ignoreproperty in svn.
    Selection of control management application

If everything went well, your project is ready.

3.2 Configuring for wmake

You should now have your project open in Qt Creator and ready to proceed to project settings. On the left side of Qt Creator click on Projects. Right now you’re looking at the Build Settings screen. This is where you set your project building and cleaning steps.

Configure build settings

4 References

This tutorial is based on: