1

I am new in qt. I have next inheritance:

class Poster : public QObject 
{
  Q_OBJECT
}

class SyncPoster: public Poster 
{
  Q_OBJECT

private slots:
  ... some functions

}

class TextPoster : public Poster
{

  Q_OBJECT

private slots:
   ... some functions

}

But assembling throws followed error:

Undefined symbols for architecture x86_64: "vtable for SyncPoster", referenced from: SyncPoster::SyncPoster(Window*, QString const&, QString const&, QString const&, QString const&) in sync_poster.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

What does it mean, and what I do wrong? Have you any ideas?

busylee
  • 2,540
  • 1
  • 16
  • 35

2 Answers2

4

One common case for this error is when you create a QObject derived class and you add or remove the Q_OBJECT without calling qmake before building.

The missing call to qmake will not trigger a re-parsing of the file and moc will not run if you just added Q_OBJECT.

SGaist
  • 906
  • 8
  • 33
  • 109
0

From a similar topic Why am I getting "Undefined symbols ... typeinfo ... vtable" with a virtual and concrete class? :

...You seem to be confusing definition with declaration. What you have in the base class is only declaration without definition, i.e. implementation. You either need to make it pure virtual or implement it even if it is just an empty {}...

Check the declaration and the definition of your constructor. Does your SyncPoster class have a public constructor? Does it have a definition? (have a body?)

SyncPoster::SyncPoster(/*...*/)

Check whether it has a body:

SyncPoster::SyncPoster(/*...*/) {}
                              //^^^  body
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51