刚刚接触KDE/Qt,正在慢慢学习,以下是我写的一个类:
#include <qapplication.h>
#include <qlabel.h>
#include <qstring.h>
#include <qwidget.h>
#include <qpainter.h>
#include <qpushbutton.h>
#include <kapp.h>
#include <stdio.h>
class threeWidget : public QWidget{
Q_OBJECT
public :
threeWidget(QWidget *parent = 0, const char *name = 0){
QWidget(parent, name);
aButton = new QPushButton("topbutton", this);
aLabel = new QLabel("thelabel", this);
//this.addWidget(aButton);
aButton->setGeometry(15, 15, 90, 20);
aLabel->setGeometry(15, 40, 90, 40);
QObject::connect(aButton, SIGNAL(clicked()), this, SLOT(buttonHandler()));
}
public slots:
void buttonHandler(){
aButton->setText("aaaaa");
}
private:
QPushButton *aButton;
QLabel *aLabel;
};
问题在于,只要加上"Q_OBJECT",编译就会报错:
************************************
main.o: In function `threeWidget':/home/larry_zb/helloworld/src/main.cpp:52: undefined reference to `vtable for threeWidget'
:/home/larry_zb/helloworld/src/main.cpp:52: undefined reference to `vtable for threeWidget'
main.o: In function `~threeWidget':/home/larry_zb/helloworld/src/main.cpp:48: undefined reference to `vtable for threeWidget'
:/home/larry_zb/helloworld/src/main.cpp:48: undefined reference to `vtable for threeWidget'
************************************
可是书上说要设置slot必须要声明"Q_OBJECT",大家帮我看看是那里错了,谢谢大家
PS: 有没有专门讲Qt Designer的电子书呀,能给小弟几本么?谢谢大家了
PS2: KDE/QT编程有没有象msdn和javadoc这样比较方便的api库的帮助亚?KDevelop连函数提示都没有,照书抄的迷迷糊糊的...