Chinaunix

标题: qtdemo的问题 [打印本页]

作者: kallytin    时间: 2014-04-07 16:27
标题: qtdemo的问题
本帖最后由 kallytin 于 2014-04-07 16:29 编辑

以下是一个简单的程序,共3个文件(main.cpp, qtdemo.cpp, qtdemo.h),详细代码如下:
  1. 1)main.cpp
  2. #include <QApplication>
  3. #include <qtdemo.h>
  4.                                                                                 
  5. int main(int argc, char **argv)
  6. {
  7.         QApplication a(argc, argv);
  8.         Demo *demo = new Demo;
  9.                                                                                 
  10.         demo->setGeometry(300,300,100,100);
  11.         demo->setWindowTitle("Qt Demo");
  12.         demo->show();
  13.                                                                                 
  14.         return a.exec();
  15. }
复制代码
  1. 2)qtdemo.cpp
  2. #include <QLabel>
  3. #include <QVBoxLayout>
  4. #include <QPushButton>
  5. #include "qtdemo.h"
  6.                                                                                 
  7. Demo::Demo()
  8. {
  9.         string = new QLabel(tr("This is a QT Demo!!"));
  10.         string->setFont(QFont("Times",20, QFont::Bold));
  11.         string->setAlignment(Qt::AlignHCenter);
  12.                                                                                 
  13.         button = new QPushButton("Quit");
  14.         button->setFont(QFont("Times",15, QFont::Bold));
  15.                                                                                 
  16.         vlayout = new QVBoxLayout;
  17.         vlayout->addWidget(string);
  18.         vlayout->addWidget(button);
  19.         setLayout(vlayout);
  20.                                                                                 
  21.         connect(button,SINGAL(clicked()),this,SLOT(close()));
  22. }
复制代码
  1. 3)qtdemo.h
  2. #ifndef __QTDEMO__
  3. #define __QTDEMO__
  4.                                                                                 
  5. #include <QWidget>
  6. class QLabel;
  7. class QVBoxLayout;
  8. class QPushButton;
  9.                                                                                 
  10. class Demo:public QWidget
  11. {
  12. public:
  13.         Demo();
  14. private:
  15.         QLabel *string;
  16.         QVBoxLayout *vlayout;
  17.         QPushButton *button;
  18. };
  19.                                                                                 
  20. #endif
复制代码
问题:
执行qtmake -project 以及 qtmake 都成功,但执行 make 时报错,错误提示如下:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
-DQT_SHARED -I/usr/local/Trolltech/Qt-4.5.3/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.5.3/include/QtCore -I/usr/local/Trolltech/Qt-4.5.3/include/QtGui -I/usr/local/Trolltech/Qt-4.5.3/include -I. -I. -o qtdemo.o qtdemo.cpp
qtdemo.cpp: In constructor `Demo:emo()':
qtdemo.cpp:20: `clicked' undeclared (first use this function)
qtdemo.cpp:20: (Each undeclared identifier is reported only once for each
   function it appears in.)
qtdemo.cpp:20: `SINGAL' undeclared (first use this function)
make: *** [qtdemo.o] Error 1


运行环境:
redhat 9
作者: kallytin    时间: 2014-04-07 16:30
回复 1# kallytin


  ding  
作者: kallytin    时间: 2014-04-07 16:56
回复 2# kallytin

有人知道吗?
   
作者: kallytin    时间: 2014-04-08 15:02
回复 1# kallytin

有人知道吗?
   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2