免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3326 | 回复: 5
打印 上一主题 下一主题

Qt,hello world编译出错。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-03-20 23:17 |只看该作者 |倒序浏览
各位我使用了最原始的Hello world 开始学习,可是qmake [project] ;qmak; make;
出错,信息和代码如下:
--------------------------------------
#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();
}
--------------------------------------
first.cpp:1:26: qapplication.h: 没有那个文件或目录
first.cpp:2:25: qpushbutton.h: 没有那个文件或目录
first.cpp: In function `int main(int, char**)':
first.cpp:7: `QApplication' undeclared (first use this function)
first.cpp:7: (Each undeclared identifier is reported only once for each
   function it appears in.)
first.cpp:7: parse error before `(' token
first.cpp:9: `QPushButton' undeclared (first use this function)
first.cpp:10: `hello' undeclared (first use this function)
first.cpp:12: `a' undeclared (first use this function)
first.cpp:6: warning: unused parameter `int argc'
first.cpp:6: warning: unused parameter `char**argv'
make: *** [first] Error 1

论坛徽章:
0
2 [报告]
发表于 2006-03-21 00:04 |只看该作者
上一个问题已经搞定了,新问题出现了
下面小程序的目的是为了把两个按钮装在一个窗口里,但是不对,求助。
#include <qapplication.h>
#include <qpushbutton.h>


int main( int argc, char **argv )
{
QApplication a( argc, argv );

QPushButton hello( "Hello world!", 0 );
QPushButton quit("Quit!",0);

hello.resize( 100, 30 );
quit.resize(100,30);
a.setMainWideget(&hello);
a.setMainWideget(&quit);
hello.show();
quit.show();
return a.exec();

}

论坛徽章:
0
3 [报告]
发表于 2006-03-21 00:06 |只看该作者
你上面的程序只适用于 4.0 以前的旧版本的 Qt。新版本的 Qt (从 4.0 开始)变化比较大。或者使用旧版的 Qt,或者用新版的文档资料学习。

论坛徽章:
0
4 [报告]
发表于 2006-03-21 00:15 |只看该作者
谢谢,不好意思啊,哪里能有新版片资料?

论坛徽章:
0
5 [报告]
发表于 2006-03-21 01:35 |只看该作者
摆平问题了,谢谢回复。

论坛徽章:
0
6 [报告]
发表于 2006-03-28 15:19 |只看该作者
这样的问题也有
??
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP