Hi there,
I'm just a newbie with Qt and I can t do a proper object inheritance with Qt. I'm trying to do a Frogger. My part is about the cars. However I try to do a vehicle class from a public QGraphicsPixmapItem but I can 't do it, it doesn't appear in the scene.
My class vehicule.h
class Vehicule : public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
Vehicule(const QPixmap &pix, QGraphicsItem *parent = 0);
QRectF boundingRect() const;
protected:
void advance(int step);
private:
QPixmap Skin;
};
My vehicule.cpp
#include "vehicule.h"
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>
#include <QStyleOption>
#include <math.h>
//! [0]
Vehicule::Vehicule(const QPixmap &pix, QGraphicsItem *parent): QGraphicsPixmapItem(parent)
{
Skin = pix;
}
//! [0]
//! [1]
QRectF Vehicule::boundingRect() const
{
qreal adjust = 0.5;
return QRectF(-18 - adjust, -22 - adjust,
36 + adjust, 60 + adjust);
}Part of my main.cpp
//VEHICULE
QPixmap WinM((":/images/windower.jpg"));
Vehicule *win = new Vehicule(WinM);
win->setZValue(1);
scene.addItem(win);
return a.exec();
Thank you for your help


Reply With Quote


Bookmarks