Extending QFrame in custom class

dominicbri7

I want to create my own custom widget that extends a QFrame, however when I am trying to make the constructor I get an error.

#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

and CPP

#include "controlframe.h"

ControlFrame::ControlFrame(QWidget *parent)
    : QFrame(parent)
{
    m_parent = parent;
}

ControlFrame::~ControlFrame()
{

}

Sadly, I get the following error

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"

What am I doing wrong?

simperreault

I think if you remove the Q_OBJECT from your .h it will be fine. I'm not sure, but because you inherit from QFrame you already have the Q_OBJECT in your object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related