• 5892阅读
  • 4回复

痛哭,跪求,好人看看,qt4头文件的问题 [复制链接]

上一主题 下一主题
离线wenyubo2008
 
只看楼主 倒序阅读 楼主  发表于: 2009-03-09
qt4头文件的问题
各位好心人:
我装的是qt4.3.2
我设置的环境变量是/etc/profile
PATH=/usr/local/Trolltech/Qt-4.3.4/bin:$PATH
3.              QTDIR=/usr/local/Trolltech/Qt-4.3.4
4.              MANPATH=$QTDIR/man:$MANPATH
5.              LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
6.              export PATH QTDIR MANPATH LD_LIBRARY_PATH
同样,qmake也默认为QT4的也一样,重定向链接。
1.              sudo rm /usr/bin/designer
2.              sudo ln -s /usr/local/Trolltech/Qt-4.3.4/bin/designer /usr/bin/designer
3.              sudo rm /usr/bin/qmake
4.              sudo ln -s /usr/local/Trolltech/Qt-4.3.4/bin/qmake /usr/bin/qmake
我编的程序是
#include <QApplication.h>
#include <QLable.h>
                                                                                                              
int main(int argc,char *argv[])
{
    QApplication app(argc,argv);
    QLable *label = new QLable("Hello Qt!");
    label->show();
    return app.exe();
}
编译用
qmake -project ,qmake hello.pro.之后用make
可是

[root@localhost hello]# make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I../mkspecs/linux-g++ -I. -I../include/QtCore -I../include/QtCore -I../include/QtGui -I../include/QtGui -I../include -I. -I. -I.
-o hello.o hello.cpp
hello.cpp:1:26: QApplication.h: 没有那个文件或目录
hello.cpp:2:20: QLable.h: 没有那个文件或目录
hello.cpp: In function `int main(int, char**)':
hello.cpp:6: `QApplication' undeclared (first use this function)
hello.cpp:6: (Each undeclared identifier is reported only once for each
   function it appears in.)
hello.cpp:6: parse error before `(' token
hello.cpp:7: `QLable' undeclared (first use this function)
hello.cpp:7: `label' undeclared (first use this function)
hello.cpp:7: parse error before `(' token
hello.cpp:9: `app' undeclared (first use this function)
hello.cpp:5: warning: unused parameter `int argc'
hello.cpp:5: warning: unused parameter `char**argv'
make: *** [hello.o] Error 1
头文件找不到
请问兄弟们
这咋办啊
离线netlove

只看该作者 1楼 发表于: 2009-03-09
#include <QApplication>
#include <QLabel>
                                                                                                              
int main(int argc,char *argv[])
{
    QApplication app(argc,argv);
    QLabel *label = new QLabel("Hello Qt!");
    label->show();
    return app.exec();
}
你应该好好检查一下你自己的程序
离线sanghk

只看该作者 2楼 发表于: 2009-03-09
你的include目录有问题,要设置include搜索的目录
离线yishu
只看该作者 3楼 发表于: 2009-03-09
试试头文件改为:
#include <QtGui/QApplication>
#include <QtGui/QLabel>
离线yanglisun
只看该作者 4楼 发表于: 2009-03-09
很明显,楼主在
#include <QAppliction>后面加了个.h
快速回复
限100 字节
 
上一个 下一个