The compile steps with Qt4 are:
- qmake -project [generates a .pro file based on the files you have in the root directory]
- qmake [genrates the Makefile from the .pro file]
- make [gnu make that uses the Makefile to generate your project as a *.app folder]
To get eclipse to follow this chain I did
- Fire up eclipse and choose File->New->C++ Project
- Uncheck 'use default location' and browse to the root of your code tree
- Enter a Project name e.g. ChhobiQT
- Pick Empty Project (leave MavOSX GCC as is)
At this stage eclipse will find your files/subdirectories and try and compile and probably give you an error. Ignore this smart ass behavior or uncheck Project->Build automatically
- Project->Properties (If this is grayed out, make sure to click and highlight ChhobiQT)
- ->C/C++ Build : Uncheck 'Generate Makefiles automatically'
- 'Build directory' set it to the variable ${project_loc}
- Run->External Tools Dialog
- Under program create a new entry and set:
Name : qmake1
Location : location of qmake on your system e.g. /usr/local/Trolltech/Qt-4.4.0/bin/qmake
Working directory : ${project_loc}
Arguments : -project
This 'External program' will enable you to generate a *.pro file when you need it
- Make an identical entry but name is qmake2 and make Arguments blank
This entry will let you generate a Makefile when you add files to the project - Now click Run->External Tools->qmake1 and then qmake2
- Hit F5 to refresh the Project explorer
You should see a .pro file and a Makefile - Project->Build Project
You should now have a *.app file - Run->Run
Your application should now run
Each time you add a new file to the configuration you need to rerun qmake -project and qmake.
Note on Code Completion:
Go to Project->Properties->C/C++ General->Paths and Symbols
In the GNU C++ tab add the following paths (depending on the version of QT)
/usr/local/Trolltech/Qt-4.4.1/include
/usr/local/Trolltech/Qt-4.4.1/include/QtGui
/usr/local/Trolltech/Qt-4.4.1/include/QtSql (if you use sql)
The rebuild code index
This will take care of code competion and things like Q_OBJECT being not recognized