#include <QGraphicsPixmapItem>class QPacMan : public QGraphicsPixmapItem{ Q_OBJECTpublic: explicit QPacMan(QGraphicsItem * parent = 0);signals:public slots:private:};....#include "QPacMan.h"#include <QGraphicsPixmapItem>QPacMan::QPacMan(QGraphicsItem * parent):QGraphicsPixmapItem(parent){ //}....#include <QApplication>#include <QtGui>#include <QPacMan.h>int main(int argc, char *argv[]){ QApplication app(argc, argv); QGraphicsView *view = new QGraphicsView; QGraphicsScene *scene = new QGraphicsScene; QPacMan *pacman = new QPacMan; view->setScene(scene); scene->addItem(pacman); scene->addPixmap(QPixmap("pacman.jpg")); view->show(); return app.exec();}
moc_QPacMan.cpp:41: error: ‘staticMetaObject’ is not a member of ‘QGraphicsPixmapItem’/usr/include/qt4/QtCore/qobject.h: In member function ‘virtual const QMetaObject* QPacMan::metaObject() const’:/usr/include/qt4/QtCore/qobject.h:296: error: ‘QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptr’ is protectedmoc_QPacMan.cpp:51: error: within this context/usr/include/qt4/QtCore/qobject.h:296: error: object missing in reference to ‘QObject::d_ptr’moc_QPacMan.cpp:51: error: from this location/usr/include/qt4/QtCore/qobject.h:296: error: ‘QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptr’ is protectedmoc_QPacMan.cpp:51: error: within this context/usr/include/qt4/QtCore/qobject.h:296: error: object missing in reference to ‘QObject::d_ptr’moc_QPacMan.cpp:51: error: from this locationmoc_QPacMan.cpp: In member function ‘virtual void* QPacMan::qt_metacast(const char*)’:moc_QPacMan.cpp:59: error: ‘qt_metacast’ is not a member of ‘QGraphicsPixmapItem’moc_QPacMan.cpp: In member function ‘virtual int QPacMan::qt_metacall(QMetaObject::Call, int, void**)’:moc_QPacMan.cpp:64: error: ‘qt_metacall’ is not a member of ‘QGraphicsPixmapItem’