collect: ld returned 1 exit status
问题:如果有自定义的类,类中定义了构造函数,和析构函数时,请注意析构函数声明了,记得定义,如果不想麻烦,在定义时可以:
1 #ifndef MYCONFIG_H
2 #define MYCONFIG_H
3
4
5 #include <QtGui/QWidget>
6 #include <QLabel>
7 #include <QLineEdit>
8
9
10 class MyPage1 : public QWidget
11 {
12 Q_OBJECT
13
14 public:
15 MyPage1(QWidget *parent = 0);
16 ~MyPage1(){};
17 QLabel *NameLabel,*HeightLabel,*NumLabel,*QuotationLabel;
18 QLineEdit *NameEdit,*HeightEdit,*NumEdit,*QuotationEdit;
19 };
20
21 class MyPage2 : public QWidget
22 {
23 Q_OBJECT
24
25 public:
26 MyPage2(QWidget *parent = 0);
27 ~MyPage2(){};
28
29 };
30 class MyPage3 : public QWidget
31 {
32 Q_OBJECT
33
34 public:
35 MyPage3(QWidget *parent = 0);
36 ~MyPage3(){};
37
38 };
39 #endif // MYCONFIG_H
#include "windows.h"
#include <QColor>
#include <QPainter>
#include <QString>
windows::windows(QWidget *parent)
: QWidget(parent)
{
resize(800,600);
pixmap = QPixmap(100,50);
background = QPixmap("background.bmp");
x = -1;
y = -1;
}
windows::~windows()
{
}
void windows::mouseMoveEvent(QMouseEvent *event){
x = event->x();
y = event->y();
pixmap.fill(QColor(255,255,255,127));
QPainter painter(&pixmap);
painter.setPen(QColor(255,0,0));
painter.drawText(20,40,QString("%1").arg(x) + "," + QString("%1").arg(y));
update();
}
void windows::paintEvent(QPaintEvent *event){
QPainter painter(this);
painter.drawPixmap(0,0,background);
painter.drawPixmap(x,y,pixmap);
}