• 4311阅读
  • 1回复

[提问]新手求教! [复制链接]

上一主题 下一主题
离线blueskychu
 

只看楼主 倒序阅读 楼主  发表于: 2012-11-19
<DIV mb10?>本人是新手,刚开始学QT,按照例题用“QT4控制台应用”模板写了两个程序,代码如下:
程序1 :
#include <QtCore/QCoreApplication><DIV mb10?>#include <QApplication><DIV mb10?>#include <QPushButton><DIV mb10?>int main( int argc, char* argv[] )<DIV mb10?>{  <DIV mb10?>  QApplication a(argc, argv );   <DIV mb10?>  QPushButton* hello = new QPushButton( "Hello world!", 0 );  <DIV mb10?>  hello -> resize( 100, 30 );  <DIV mb10?>  hello -> show();  <DIV mb10?>  return a.exec();<DIV mb10?>}<DIV mb10?>程序2:
#include <QtCore/QCoreApplication><DIV mb10?>#include <QApplication><DIV mb10?>#include <QPushButton><DIV mb10?>#include <QFont><DIV mb10?>int main(int argc, char *argv[])<DIV mb10?>{    <DIV mb10?>  QApplication a(argc, argv);    <DIV mb10?>  QPushButton quit=new QPushButton( "Quit", 0 );    <DIV mb10?>  quit->resize( 75, 30 );    <DIV mb10?>  quit->setFont( QFont( "Times", 18, QFont::Bold ) );    <DIV mb10?>  QObject::connect( &quit, SIGNAL(clicked()), &a, SLOT(quit()) );   <DIV mb10?>  a.setMainWidget( &quit );    <DIV mb10?>  quit.show();    <DIV mb10?>  return a.exec();}<DIV mb10?>程序1运行没有问题,但程序2编译时提示:
(1)QApplication:NO such file or directory.
  (2)  QPushButton:NO such file or directory.
......
我感到很疑惑,QApplication和QPushButton在程序1中都用到,能够正确编译,为何到了程序2中就不能正确编译?恳请高手赐教!
离线roywillow

只看该作者 1楼 发表于: 2012-11-19
代码请重新排版
检查一下pro文件中QT+=一行有没有gui一项
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
快速回复
限100 字节
 
上一个 下一个