Qt in Eclipse on Debian

install

apt install eclipse-cdt eclipse-cdt-qt libqt4-dev

create new C++ Project
(e.g. Hello World C++ Project)

File->New->C++ Project

edit Project settings and add the following includes and libraries

Project->Properties->C/C++ Build->Settings->GCC C++ Compiler->Includes

/usr/include/qt4
/usr/include/qt4/Qt
/usr/include/qt4/QtCore
/usr/include/qt4/QtGui

eclipseincludes

Project->Properties->C/C++ Build->Settings->GCC C++ Linker->Libraries

QtCore
QtGui

eclipselibraries

now you can compile and run the following code:

#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[]) {
QApplication QtApp(argc, argv);
QLabel QtLabel;
QtLabel.setText("!!!Hello World!!!");
QtLabel.show();
QtApp.exec();
}

compile:
Project->Build Project

Debug:
Run->Debug as->Local C/C++Application

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.