I made simple game to shot rectangle(class Bullet) from other rectangle(class MyRect). I have error undefined reference to 'vtable for bullet'. I have written that is connected with Q_OBJECT and moc.I can't resolve this problem.
Bullet.h
#ifndef BULLET_H
#define BULLET_H
#ifndef Q_MOC_RUN
#include <QGraphicsRectItem>
#include <QObject>
class Bullet: public QObject,public QGraphicsRectItem{
    Q_OBJECT
public:
    Bullet();
public slots:
    void move();
};
#endif
#endif // BULLET_H
MyRect.h
#ifndef MYRECT_H
#define MYRECT_H
#include <QGraphicsRectItem>
class MyRect: public QGraphicsRectItem{
public:
    void keyPressEvent(QKeyEvent* event);
};
#endif // MYRECT_H
Bullet.cpp
#include "Bullet.h"
#include <QTimer>
Bullet::Bullet(){
    setRect(0,0,10,50);   
    QTimer * timer = new QTimer();
    connect(timer,SIGNAL(timeout()),this,SLOT(move()));
    timer->start(50);
}
void Bullet::move(){
    this->setPos(x(),y()-10);
}
main.cpp
#include <QApplication>
#include <QGraphicsScene>
#include "MyRect.h"
#include <QGraphicsView>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QGraphicsScene * scene = new QGraphicsScene();
    MyRect * rect = new MyRect();
    rect->setRect(0,0,100,100);
    rect->setFlag(QGraphicsItem::ItemIsFocusable);
    rect->setFocus();
    scene->addItem(rect);
    QGraphicsView * view = new QGraphicsView(scene);
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->show();
    return a.exec();
}
MyRect.cpp
#include "MyRect.h"
#include<QKeyEvent>
#include <QGraphicsScene>
#include "Bullet.h"
#include<QDebug>
void MyRect::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Left)
    {
        setPos(x()-10,y());
    }
    else if(event->key() == Qt::Key_Right)
    {
        setPos(x()+10,y());
    }
    else if(event->key() == Qt::Key_Up)
    {
        setPos(x(),y()-10);
    }
    else if(event->key() == Qt::Key_Down)
    {
        setPos(x(), y()+10);
    }
    else if(event->key() == Qt::Key_Space)
    {
        Bullet * bullet = new Bullet();
        bullet->setPos(x(), y());
        scene()->addItem(bullet);
    }
}
I have written some similar error i Qt, but still i can't resolve my.Thank you very much for your attention.
 
     
    