baojian_322 发表于 2006-11-13 14:45:19

请教 Qt 的的问题

我用的是redhat9.0,自带的qt-3.1,刚开始使用,想那个简单程序先运行一下,
当我使用qtdesigner编辑好程序后,运行出现错误,请各位指教。hehe.pro是工程的名字

$ qmake hehe.pro
$ 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();
}

谢谢各位大侠指点!!

cavendish 发表于 2006-11-13 20:49:18

配置好QTDIR, PATH, LD_LIBRARY_PATH等变量

baojian_322 发表于 2006-11-13 22:36:25

谢谢您的回复,不过我已经设置这些变量了,还是不能通过,具体是这样设置的:

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

exportQTDIRPATHLD_LIBRARY_PATH

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

cavendish 发表于 2006-11-13 23:09:31

那你检查一下$QTDIR/include下有文件么?
是不是没装qt-devel包?

强烈建议自己编译一下Qt

baojian_322 发表于 2006-11-15 14:10:23

下面是我所检查安装包的情况:
# 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的过程吗,谢谢!!

cavendish 发表于 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
页: [1]
查看完整版本: 请教 Qt 的的问题