I'm new to Qt and trying to learn the Graphics and Animation frameworks. I created a simple app that using code pulled from the AnimatedTiles example app,but I cannot get it to compile.

The apps consist of main.cpp, posterimg.cpp and posterimg.h.

PosterImg is the same as the Pixmap class in the AnimatedTiles sample. I'm simply renamed it and moved it out of the main class. Unfortunately, now the app won't compile. Compiling produces the following errors:

posterimg.cpp:4: error: ISO C++ forbids declaration of 'PosterImage' with no type
posterimg.cpp:4: error: no 'int PosterImg::PosterImage(QPixmap&)' member function declared in class 'PosterImg'


Can anybody show me what I'm doing wrong?

Code for PosterImg.h

Qt Code:
  1. #ifndef POSTERIMG_H
  2. #define POSTERIMG_H
  3.  
  4. #include <QPixmap>
  5. #include <QGraphicsPixmapItem>
  6.  
  7. class PosterImg : public QObject, public QGraphicsPixmapItem
  8. {
  9. Q_OBJECT
  10. Q_PROPERTY(QPointF pos READ WRITE setPos)
  11.  
  12. public:
  13. PosterImg(QPixmap &pix);
  14.  
  15.  
  16. };
  17.  
  18. #endif // POSTERIMG_H
To copy to clipboard, switch view to plain text mode 

Code for PosterImg.cpp

Qt Code:
  1. #include "posterimg.h"
  2.  
  3.  
  4. PosterImg::PosterImage(QPixmap &pix)
  5. {
  6. setCacheMode(DeviceCoordinateCache);
  7. }
To copy to clipboard, switch view to plain text mode 

Code for main.cpp
Qt Code:
  1. #include <QtCore>
  2. #include <QtGui>
  3.  
  4.  
  5. #include "posterimg.h"
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. Q_INIT_RESOURCE(uc1res);
  10. QApplication app(argc, argv);
  11.  
  12. textItem->setHtml("<font color=\"black\"><b>Hello</b>");
  13. textItem->setPos(100,50);
  14.  
  15. QPixmap myPix(":/images/kinetic.png");
  16. PosterImg *myImg = new PosterImg(myPix);
  17.  
  18. scene.addItem(img);
  19. scene.addItem(textItem);
  20. scene.setBackgroundBrush(Qt::white);
  21.  
  22. view.setRenderHints(QPainter::Antialiasing);
  23. view.setTransformationAnchor(QGraphicsView::NoAnchor);
  24. view.setScene(&scene);
  25. view.show();
  26. view.setFocus();
  27.  
  28.  
  29. return app.exec();
  30. }
To copy to clipboard, switch view to plain text mode 

Brian