Community
Participate
Working Groups
This is not really a bug but more like a sudjestion to create a tutorial on building applications using eclipse and Qt. Let me first say that I am new to the CDT project and also new to Qt. I and just trying to build the typical Hello World application within eclipse using Qt. I was able to build the hello world program so I am posting here the way I did it. Hopefully this can start a better tutorial or motivate more people to start using the CDT project and Qt. Who knows :) My machine configuration is as follows: Linux Mandrake 10 Eclipse Linux (x86/GTK 2) CDT 2.0 Qt version 3 ////////////////////////////////////////////////////////////////// Here are a few of my environmental variables: (Adjust these in .bashrc according to your needs) export QTDIR=/usr/lib/qt3 export KDEDIR=/usr export PATH=$QTDIR/bin:$KDEDIR/bin:$PATH export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH ////////////////////////////////////////////////////////////////// Lets first test Qt to make sure we have all the requirements. Make sure that you can create the application from the command line by doing the following: Type the following code and name it: hello.cpp ////////////////////////////////////////////////////////////////// #include <qapplication.h> #include <qpushbutton.h> int main( int argc, char **argv ) { QApplication a( argc, argv ); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); a.setMainWidget( &hello ); hello.show(); return a.exec(); } // leave an empty line after this ////////////////////////////////////////////////////////////////// After typing and saving the above code enter at the command prompt the following: (make sure you are inside the folder where hello.cpp is) qmake -project qmake make the first creates a qmake project the second creates the Makefile needed by the make utility the last builds the Makefile created in step #2 (creates an executable file) ////////////////////////////////////////////////////////////////// STOP READ THIS: If you are able to do all the previous steps and the program compiles fine then you are good to go with eclipse. Make sure you run the program you just created runs. The file name should be the name of the folder in which you are. So run it like this: ./FOLDERNAME ////////////////////////////////////////////////////////////////// Now lets do the same but with eclipse: Go to eclipse and open the C/C++ perspective Create a new project using C++ then click on "Standard Make C++ Project" Click next and name the project QtHello then click on finish when done. Now create a new file and name it hello.cpp Type the previous code for hello.cpp and make sure you leave and empty line at the end. Right click on the C/C++ Projects tab and select "Build Make Target" On this window we will enter the 3 make targets that we used above. 1) Click on Add The target name will be "QBuild Project" Make Target: (leave this blank) (ERASE "All") uncheck "use default" Build command: qmake -project Click on Create 2) Click on Add The target name will be "QBuild Makefile" Make Target: (leave this blank) (ERASE "All") uncheck "use default" Build command: qmake Click on Create 3) Click on Add The target name will be "Build Project" *** Do not change anything else **** Finally click on cancel to exit this window (The information is allready saved) We just created our make programs. Before continuing "make sure the hello.cpp file is saved" or you have autosave turn on. Notice that every commands that we will execute next will show up on the Console tab. Open up the Make Targets tab There you will see the project we just created (QtHello) Lets start building: Click the down arrow on the project and there will be the 3 make targets First double click on "QBuild project" to create the QtHello.pro file Second double click on "QBuild Makefile" to create our Makefile Last double click on "Build Project" to create QtHello We are done. Lets execute the file Go to the Navigation tab and right click on the file QtHello select Run.. Run C Local Application p.s. If a screens opens up asking for "Launch Debug Configuration Selection" select "GDB Debugger" A new window should have opened up with our program. :-) THE END I hope this file helps anyone or creates a new tutorial in the help files of eclipse. Thank you for your time and hopefully constructive criticism. --Albert
I would like to propose a way to build qmake projects from eclipse. Have the option in: New -> Project -> C++ -> Standard Qt C++ Project using QMake This should setup the 3 "Make Targets" needed to build the application: qmake -project qmake make Maybe the 3 files can be executed one after the other in a batch file. That would avoid missing files during the make process specially any new files that were added latter to the project. What do you guys think? --Albert
That would make it an enhancement request.
Future means you commit to fix it in the Future. Inboxes can't make committments. Moving to '--'.