Results 1 to 4 of 4

Thread: Howto use Eclipse with QT4 in 10 steps

  1. #1
    Join Date
    Sep 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Howto use Eclipse with QT4 in 10 steps

    I write this simple howto that explains how to setup and use Eclipse to build QT4 applications.
    I hope this is useful for QT programmaers ;-)
    the_bis



    Howto use Eclipse with QT4 in 10 steps

    QT version: 4.2.2-x11
    Eclipse version: eclipse-*-3.1.2-1jpp_15fc
    Linux distro: Fedora Core 5


    1. Choose your existing QT project
    For example my project was in "/home/test/myQTProj" and my files are: myQTProj.pro, main.cpp, myQTProj.h, myQTProj.cpp

    2. Setup environment
    Check if you have the right environment path. In my sytem I have to set the $PATH variable:
    export PATH=/usr/local/Trolltech/Qt-4.2.2/bin:$PATH

    3. Launch Eclipse

    4. Set up eclipse for use with Qt
    Set the right path to reach "qmake" and "assitant". To do so click on "Run/External Tools/External Tools" menu and create 2 new "Program":

    - Name: QMake
    - Location: /usr/local/Trolltech/Qt-4.2.2/bin/qmake (change it to your needs)

    - Name: QTAssistant
    - Location: /usr/local/Trolltech/Qt-4.2.2/bin/assistant (change it to your needs)

    Create the right file-type associations to handle QT Designer and Linguist files. To do so click "Window/Preferences/General/Editors/File Associations" and add file extensions for .ui and .ts files:
    - *.ui -> designer
    - *.ts -> linguist

    Note: this setup has to be done only the first time you use Eclipse.

    5. Create a workspace for use with your C++ QT project
    Create a new "Standard Make C++ Project" (with the "File/New/Standard Make C++ Project" dialog).
    Choose a name for your project.
    Unflag "Project contents/Use default" and choose your existing project directory.
    Click "Next" button and at tab named "C/C++ Indexer" (the last one) choose "Full C/C++ Indexer".
    Click "Finish".
    You will see all your project sub-directories, "*.cpp", "*.h" and "*.pro" files in the left "C/C++ Projects" panel.

    6. Create our make targets
    Open up the "Make Targets View" in Eclipse ("Window/Show View/Make Targets" - in my setup this is on the right part of the Eclipse window), click right-mouse on the project's name and add two new "Targets":

    - Target Name: qmake
    - Make Target: myQTProj.pro (change it to your needs)
    - Build Command: qmake (unflag and change this option)

    - Target Name: all
    - Make Target: all
    - Build Command: default (make)

    7. Make "Makefile" -> run qmake command
    Double click on the "qmake" target and take a look to the "Console" View in Eclipse. If the command was successfull, there is now a makefile in your project directory which can be used to build your app program.

    8. Make your executable -> run make command
    Double click on the "make" target to build your QT application.

    9. Note
    If will start the C/C++ Indexer don't worry: it will take some minutes to browse all the files it needs. The problem is that the Indexer continue to start and slow down the coding work... Any solution?
    This howto was inspired by this article: Qt4 in Eclipse - http://scroogie.de/index.php?/archiv...n-Eclipse.html

    10. Enjoy ;-)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Howto use Eclipse with QT4 in 10 steps

    Maybe you could also add it to our wiki?

  3. #3
    Join Date
    Sep 2006
    Posts
    27
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Howto use Eclipse with QT4 in 10 steps

    Quote Originally Posted by wysota View Post
    Maybe you could also add it to our wiki?
    Done
    You can find it here: http://wiki.qtcentre.org/index.php?t...T4_in_10_steps

    the_bis

  4. #4
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Howto use Eclipse with QT4 in 10 steps

    A few more that I use:
    For step 4 you could use QtClipse. The first versions waren't that much but now it's pretty usable and straightforward. You just get some syntax highlighting for .pro files and easy invocation of qmake on .pro files. Simple and effective. Also I would suggest under Project->Properties->C/C++ Include Paths to add the path to the Qt headers so you get code completion for Qt. I 'm using Eclipse 3.2.1 on Ubuntu and Windows.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.