QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1890|回复: 5

请教 Qt 的的问题

[复制链接]
发表于 2006-11-13 14:45:19 | 显示全部楼层 |阅读模式
我用的是redhat9.0,自带的qt-3.1,刚开始使用,想那个简单程序先运行一下,
当我使用qtdesigner编辑好程序后,运行出现错误,请各位指教。hehe.pro是工程的名字

[lili@localhost lili]$ qmake hehe.pro
[lili@localhost lili]$ make
g++ -c -pipe -Wall -W -O2 -march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions  -DQT_NO_DEBUG -I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/main.o main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:8: `QPushButtton' undeclared (first use this function)
main.cpp:8: (Each undeclared identifier is reported only once for each function
   it appears in.)
main.cpp:8: parse error before `(' token
main.cpp:9: `hellobtn' undeclared (first use this function)
make: *** [.obj/main.o] Error

下面是我的程序:
#include <qapplication.h>
#include <qpushbutton.h>

int main( int argc,char **argv)

{
QApplication a(argc,argv);

QPushButton hellobtn("hello world!",0);
hellobtn.resize(100,20);
a.setMainWidget(&hellobtn);
hellobtn.show();
return a.exec();
}

谢谢各位大侠指点!!
发表于 2006-11-13 20:49:18 | 显示全部楼层
配置好QTDIR, PATH, LD_LIBRARY_PATH等变量
回复

使用道具 举报

 楼主| 发表于 2006-11-13 22:36:25 | 显示全部楼层
谢谢您的回复,不过我已经设置这些变量了,还是不能通过,具体是这样设置的:

QTDIR=usr/lib/qt-3.1
PATH=$QTDIR/bin:$PATH
LD_LIBRARY_PATH=$QTDIR/bin:$LD_LIBRARY_PATH

export  QTDIR  PATH  LD_LIBRARY_PATH

然后我把它放在了/etc/profile 中,请问这样做正确吗?谢谢回复
回复

使用道具 举报

发表于 2006-11-13 23:09:31 | 显示全部楼层
那你检查一下$QTDIR/include下有文件么?
是不是没装qt-devel包?

强烈建议自己编译一下Qt
回复

使用道具 举报

 楼主| 发表于 2006-11-15 14:10:23 | 显示全部楼层
下面是我所检查安装包的情况:
[root@localhost root]# rpm -qa | grep qt
qt-devel-3.1.1-6
qt2-2.3.1-13
qt2-Xt-2.3.1-13
qt-3.1.1-6
qtcups-2.0-15
qt-PostgreSQL-3.1.1-6
qt2-designer-2.3.1-13
qt-designer-3.1.1-6
licq-qt-1.2.3-5
qt-MySQL-3.1.1-6
qt2-devel-2.3.1-13
qtcups-devel-2.0-15
qt-ODBC-3.1.1-6
qt-Xt-3.1.1-6
qt2-static-2.3.1-13

另外下面的是我所加的环境变量的位置,请问是否正确?
/etc/profile.d/qt.sh
# Qt initialization script (sh)
if [ -z "$QTDIR" ] ; then
        QTDIR="/usr/lib/qt-3.1"
        PATH=$QTDIR/bin:$PATH
        LD_LIBRARY_PATH=$QTDIR/bin:$LD_LIBRARY_PATH
fi
export QTDIR PATH LD_LIBRARY_PATH

是否是加在/etc/profile呢?

我是菜鸟,如果重新编译的话,您能详细介绍一下重新编译Qt的过程吗,谢谢!!
回复

使用道具 举报

发表于 2006-11-15 19:34:58 | 显示全部楼层
http://www.qiliang.net/20040225.html

http://www.qtopia.org.cn/phpBB2/viewtopic.php?t=437
http://www.qtopia.org.cn/phpBB2/viewtopic.php?t=414
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-2 16:18 , Processed in 0.059688 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表