我在redhat9 下安装了Qt4
在etc/profile最后添加
QTDIR=/usr/local/Qt
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH
安装完打开designer
试着编程代码如下:
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
int main(int argc,char **argv)
{
QApplication a(argc,argv);
QWidget mainwindow;
mainwindow.setMinimumSize(200,100);
mainwindow.setMaximumSize(200,100);
QPushButton helloworld("hello,world!",&mainwindow);
helloworld.setGeometry(20,20,160,60);
a.setMainWidget(&mainwindow);
mainwindow.show();
return a.exec();
}
然后,g++ -lqt hello.cpp -o hello 说找不到头文件
换用qmake -prject 然后qmake 出现如下说明:
/usr/local/qt/mkspecs/linux-g++/qmake.conf:90: Unknown test function: load
我接着make,出错:
hello.cpp:1:26: qapplication.h: No such file or directory
hello.cpp:2:21: qwidget.h: No such file or directory
hello.cpp:3:25: qpushbutton.h: No such file or directory
不知什么原因,谢谢指教