[Qt-interest] QGraphicsItem Error

varun singh mailthatmale at yahoo.co.in
Tue Aug 11 19:34:00 CEST 2009


hi,
Please have a look at this code.
It spans over two files: a header file and a source file. I'm pretty sure I have done the file inclusions properly, there is no error in that.

Code:
**************************************************************************

class Tank : public QGraphicsItem
{
    Q_OBJECT

public:
    Tank();
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QPainterPath shape() const;
    QRectF boundingRect() const;

private:
    QPixmap *mTank;
};

Tank::Tank()
{
    setFlags(ItemIsMovable);
}

void Tank::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{

    painter->drawPixmap(0, 0, 30, 50, QPixmap(":/images/Tank.png"));
}

QRectF Tank::boundingRect() const
{
    return (QRect(0, 0, 35, 55));
}

QPainterPath Tank::shape() const
{
    QPainterPath p;
    p.addRect(boundingRect());
    return p;
}


**************************************************************************

The above code is giving the following error.

Error:
**************************************************************************
Starting: G:/Qt/2009.02/mingw/bin/mingw32-make.exe -w 
G:\Qt\2009.02\mingw\bin\mingw32-make.exe: Entering directory `G:/Qt-Projects/Gui Appl/Tanks'
G:/Qt/2009.02/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[1]: Entering directory `G:/Qt-Projects/Gui Appl/Tanks'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\Qt\2009.02\qt\include\QtCore" -I"..\..\..\Qt\2009.02\qt\include\QtGui" -I"..\..\..\Qt\2009.02\qt\include" -I"..\..\..\Qt\2009.02\qt\include\ActiveQt" -I"debug" -I"." -I"..\..\..\Qt\2009.02\qt\mkspecs\win32-g++" -o debug\moc_tank.o debug\moc_tank.cpp
debug\moc_tank.cpp:39: error: `staticMetaObject' is not a member of `QGraphicsItem'
debug\moc_tank.cpp: In member function `virtual void* Tank::qt_metacast(const char*)':
debug\moc_tank.cpp:53: error: `qt_metacast' is not a member of `QGraphicsItem'
debug\moc_tank.cpp: In member function `virtual int Tank::qt_metacall(QMetaObject::Call, int, void**)':
debug\moc_tank.cpp:58: error: `qt_metacall' is not a member of `QGraphicsItem'
mingw32-make.exe[1]: Leaving directory `G:/Qt-Projects/Gui Appl/Tanks'
G:\Qt\2009.02\mingw\bin\mingw32-make.exe: Leaving directory `G:/Qt-Projects/Gui Appl/Tanks'
mingw32-make.exe[1]: *** [debug/moc_tank.o] Error 1
G:\Qt\2009.02\mingw\bin\mingw32-make.exe: *** [debug] Error 2
Exited with code 2.
Error while building project Tanks
When executing build step 'Make'
***************************************************************************

This error is a total mystery to me. All I know that it has something to do with QGraphicsItem. Seeking for help.

-Varun



-Varun


      Looking for local information? Find it on Yahoo! Local http://in.local.yahoo.com/




More information about the Qt-interest-old mailing list