5

I have downloaded Eclipse with the plug-in to work with C/C++ over Windows. I downloaded Cygwin (base and devel mostly) and works ok for a hello world application.

Now I want to work with Qt. Instead of downloading the framework, I downloaded the libraries "Qt libraries 4.8.0 for Windows (minGW 4.4, 354 MB)", since the other option was the same thing for Visual Studio. I know this could be part of the problem, since it looks to be made only for minGW compiler. If I need to do things in a different way, please tell.

Then I restarted computer, opened Eclipse, wrote this Qt hello world for a new C++ application with Cygwin compiler:

#include <qapplication.h>
#include <qpushbutton.h>

using namespace std;

int main( int argc, char * args[] )
{
    cout << "Here goes!" << endl;

    QApplication app( argc, args );
    QPushButton hello( "Hello World!", 0 );
    hello.resize( 100, 50 );
    app.setMainWidget( &hello );
    hello.show();
    return app.exec();
}

And compiler doesn't find the .h files included. Could it need me to add Qt\bin path to the enviroment variables?

Maybe I should stick to the Qt framework, as it looks like a compiler itself (I really don't know how that works, since yesterday I thought Qt was just a library).

Please tell me what I'm doing wrong (I hope answer to this is not "EVERYTHING" hehe) and how can I make this work.

Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
  • did installed the plugin for integrating eclipse with qt? – shofee Mar 13 '12 at 09:48
  • I did, and I have also added the Qt\bin folder to PATH in enviroment variables. Also installed MinGW as most tutorials explain instead of using Cygwin. Nothing changes – Roman Rdgz Mar 13 '12 at 11:18

1 Answers1

2

The QT framework implements a meta-language over the top of C++ which QT uses to create its event handling framework (google qt slots and signals for more information). Standard compilers such as G++ don't understand this meta-language so it has to be translated first. You can do this through eclipse by maintaining your own makefile and running QT's Meta-Object-Compiler over the top of the code before you compile it (see this page for more details).

My approach would be to use the QTCreator toolkit to do your compilation, even if you don't use it as your IDE. Also consider using Eclipse and qmake, which if I remember correctly, automatically uses the MOC translater as part of its process.

Good luck!

  • So, I should use Qt's qmake as my compiler, and not Cygwin or minGQ. I guess that's what QTCreator does beneath. Is that right? In that case, how can I use qmake as my compiler from Eclipse? It is not listed as an option when I select a compiler tool when creating a new project. – Roman Rdgz Mar 13 '12 at 08:28
  • 1
    no you use both. qmake process Qt specific keywords and generate C++ files (and a makefile), then your compiler use the makefile for the files. Your question is nice but Qtcreator is so much more appropriate imho. – UmNyobe Mar 13 '12 at 09:28
  • 1
    I have to agree with UmNyobe. In theory you could set up eclipse to use qmake as a build system. However, it would probably be a lot more bother than just using QTCreator. Please see [this post](http://stackoverflow.com/questions/7775398/eclipse-qt-and-c-project-is-it-possible) – James Ravenscroft Mar 13 '12 at 10:18