Chinaunix
标题:
qtdemo的问题
[打印本页]
作者:
kallytin
时间:
2014-04-07 16:27
标题:
qtdemo的问题
本帖最后由 kallytin 于 2014-04-07 16:29 编辑
以下是一个简单的程序,共3个文件(main.cpp, qtdemo.cpp, qtdemo.h),详细代码如下:
1)main.cpp
#include <QApplication>
#include <qtdemo.h>
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Demo *demo = new Demo;
demo->setGeometry(300,300,100,100);
demo->setWindowTitle("Qt Demo");
demo->show();
return a.exec();
}
复制代码
2)qtdemo.cpp
#include <QLabel>
#include <QVBoxLayout>
#include <QPushButton>
#include "qtdemo.h"
Demo::Demo()
{
string = new QLabel(tr("This is a QT Demo!!"));
string->setFont(QFont("Times",20, QFont::Bold));
string->setAlignment(Qt::AlignHCenter);
button = new QPushButton("Quit");
button->setFont(QFont("Times",15, QFont::Bold));
vlayout = new QVBoxLayout;
vlayout->addWidget(string);
vlayout->addWidget(button);
setLayout(vlayout);
connect(button,SINGAL(clicked()),this,SLOT(close()));
}
复制代码
3)qtdemo.h
#ifndef __QTDEMO__
#define __QTDEMO__
#include <QWidget>
class QLabel;
class QVBoxLayout;
class QPushButton;
class Demo:public QWidget
{
public:
Demo();
private:
QLabel *string;
QVBoxLayout *vlayout;
QPushButton *button;
};
#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