我想创建自己的扩展 QFrame 的自定义小部件,但是当我尝试创建构造函数时出现错误。
#ifndef CONTROLFRAME_H
#define CONTROLFRAME_H
#include <QObject>
#include <QFrame>
#include <QWidget>
#include <QtGui>
class ControlFrame : public QFrame
{
Q_OBJECT
public:
ControlFrame(QWidget *parent = 0);
~ControlFrame();
private:
QWidget *m_parent;
};
#endif // CONTROLFRAME_H
和 CPP
#include "controlframe.h"
ControlFrame::ControlFrame(QWidget *parent)
: QFrame(parent)
{
m_parent = parent;
}
ControlFrame::~ControlFrame()
{
}
可悲的是,我收到以下错误
Undefined symbols for architecture x86_64:
"vtable for ControlFrame", referenced from:
ControlFrame::ControlFrame(QWidget*) in controlframe.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [PFEtest.app/Contents/MacOS/PFEtest] Error 1
18:54:21: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project PFEtest (kit: Desktop Qt 5.4.0 clang 64bit)
When executing step "Make"
我究竟做错了什么?