• 6338阅读
  • 3回复

QT4.4.3安装求助-为什么编译程序找不到相应类? [复制链接]

上一主题 下一主题
离线junesin
 
只看楼主 倒序阅读 楼主  发表于: 2008-10-27
— 本帖被 XChinux 执行加亮操作(2008-11-02) —
按要求正确的安装了QT4.4.2(采用自动下再也安装MinGW),没有在系统变量中设置路径。在QT4.4.3 command prompt窗口(自动设置了搜索路径)运行hello测试程序出错。什么原因?程序如下
#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();
}
错误窗口如下
离线junesin
只看该作者 1楼 发表于: 2008-10-27
图形没加载上,采用文本显示编译过程如下
执行命令
d:\downloads\hello>qmake -project
d:\downloads\hello>qmkae
d:\downloads\hello>make
错误如下:
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `D:/Downloads/hello'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtCore" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include\QtGui" -I"c:\Qt\4.4.3\include" -I"." -I"c:\Qt\4.4.3\include\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.3\mkspecs\win32-g++" -o debug\hello.o hello.cpp

hello.cpp:In function 'int qMain<int,char**>':
hello.cpp:18:error 'class QApplication' has no member named 'setMainWidget'
mingw32-make[1]:*** [debug/hello.o] Error1
mingw32-make[1]:Leaving directory 'D:/Downloads/hello'
mingw32-make: *** [debug] Error2
离线junesin
只看该作者 2楼 发表于: 2008-10-31
自己回答吧,请教了热心的网友,主要问题是使用了QT3的程序,但用QT4编译,因为两个版本不同,QT4不能识别QT3的程序,从而导致上述错误。
离线wd007

只看该作者 3楼 发表于: 2008-12-13
遇到过类似问题
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
快速回复
限100 字节
 
上一个 下一个