I'm trying to compile the next Qt code:
Code:
#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();
}
But first I had this problem:
Code:
hello.cpp:1:125: error: qapplication.h: No such file or directory
hello.cpp:2:125: error: qpushbutton.h: No such file or directory
hello.cpp: In function ‘int main(int, char**)’:
hello.cpp:6: error: ‘QApplication’ was not declared in this scope
hello.cpp:6: error: expected `;' before ‘a’
hello.cpp:7: error: ‘QPushButton’ was not declared in this scope
hello.cpp:7: error: expected `;' before ‘hello’
hello.cpp:8: error: ‘hello’ was not declared in this scope
hello.cpp:9: error: ‘a’ was not declared in this scope
Then I installed libqt4-dev with apt-get and now I'm having the next problem
Code:
joakim@leho:~/qt$ g++ -Wall -I/usr/include/qt4/Qt -L/usr/lib hello.cpp -l hello -lqt
In file included from hello.cpp:1:
/usr/include/qt4/Qt/qapplication.h:27:37: error: QtCore/qcoreapplication.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:28:31: error: QtGui/qwindowdefs.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:29:27: error: QtCore/qpoint.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:30:26: error: QtCore/qsize.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:31:27: error: QtGui/qcursor.h: No such file or directory
In file included from hello.cpp:2:
/usr/include/qt4/Qt/qpushbutton.h:27:35: error: QtGui/qabstractbutton.h: No such file or directory
/usr/include/qt4/Qt/qapplication.h:44: error: ‘QT_BEGIN_HEADER’ does not name a type
/usr/include/qt4/Qt/qapplication.h:64: error: invalid function declaration
/usr/include/qt4/Qt/qapplication.h:336: error: ‘QT_END_HEADER’ does not name a type
/usr/include/qt4/Qt/qpushbutton.h:36: error: invalid function declaration
hello.cpp:4: error: expected constructor, destructor, or type conversion before ‘int’
Are the Qt library headers installed wrongly or what is the problem?
Code:
joakim@leho:~/qt$ find /usr/ -iname qcoreapplication.h
/usr/include/qt4/Qt/qcoreapplication.h
/usr/include/qt4/QtCore/qcoreapplication.h
Thank you for your time and help.