PDA

View Full Version : QGraphicsItem - issue



sajis997
16th November 2011, 12:03
Hello Forum,

I am subclassing the QGraphicsItem as follows:





class RootGraphicsItem : public QObject , public QGraphicsItem
{
Q_OBJECT
public:






And i am getting the error inside the paint function :




RootGraphicsItem.cpp: In member function ‘virtual void RootGraphicsItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*)’:
RootGraphicsItem.cpp:473: error: invalid use of incomplete type ‘struct QPainter’
/usr/include/qt4/QtGui/qwindowdefs.h:64: error: forward declaration of ‘struct QPainter’
RootGraphicsItem.cpp:488: error: invalid use of incomplete type ‘struct QPainter’
/usr/include/qt4/QtGui/qwindowdefs.h:64: error: forward declaration of ‘struct QPainter’
RootGraphicsItem.cpp:489: error: invalid use of incomplete type ‘struct QPainter’
/usr/include/qt4/QtGui/qwindowdefs.h:64: error: forward declaration of ‘struct QPainter’
RootGraphicsItem.cpp:491: error: invalid use of incomplete type ‘struct QPainter’
/usr/include/qt4/QtGui/qwindowdefs.h:64: error: forward declaration of ‘struct QPainter’
RootGraphicsItem.cpp:492: error: invalid use of incomplete type ‘struct QPainter’
/usr/include/qt4/QtGui/qwindowdefs.h:64: error: forward declaration of ‘struct QPainter’
RootGraphicsItem.cpp: At global scope:





Any hint on what i am missing ?


Regards
Sajjad

Lykurg
16th November 2011, 13:51
The error message is telling you all you need! Include QPainter:
#include <QtGui/QPainter>

Spitfire
16th November 2011, 14:25
[deleted]
Aghhh I should refresh the page next time before going for Quick Reply ;)