bute
bute

Reputation: 79

in Qt, my class inherit QObject error with "vtable for GameControlCenter", referenced from:

The total error message is:

Undefined symbols for architecture x86_64:

"vtable for GameControlCenter", referenced from:

GameControlCenter::GameControlCenter() in gamecontrolcenter.o

NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.

The head is:

#ifndef GAMECONTROLCENTER_H
#define GAMECONTROLCENTER_H

#include "gamewindows.h"
#include <QList>
#include <QPair>
#include <QObject>


class GameControlCenter:public QObject
{
Q_OBJECT
public:
GameControlCenter(); 

QUESTION:

The error become When

the GameControlCenter inherit QObject and add macro "Q_OBJECT".

Before this opertaion, these code can run normaly. But I need to add slots function in GameControlCenter head, so I need to inherit QObject.

IDE

OS is OS X10.11.2. Qt Creator

Upvotes: 1

Views: 561

Answers (1)

bute
bute

Reputation: 79

  • Make sure the Q_OBJECT macro is present in the definition of all QObject-derived classes.
  • Make sure you declare your QObject-derived classes in your header files only.
  • Make sure all of your header files are listed in your .pro file in the HEADERS= list.
  • Run qmake every time you add Q_OBJECT to one of your classes or modify your .pro file

In my code, I repeat call this head file. So if you have the same question, please check your code whether include same file again.

Upvotes: 2

Related Questions