Archa4
8th March 2011, 08:11
I need to create a custom calendar, where i need to change the look of each cell that contains a date. I tried this:
class CustomCalendarWidget : public QCalendarWidget
{
Q_OBJECT
public:
CustomCalendarWidget( QWidget* parent = 0 ) : QCalendarWidget( parent ) {}
~CustomCalendarWidget() {}
protected:
virtual void paintCell( QPainter* painter, const QRect& rect, const QDate& date ) const
{
painter->setPen( Qt::black );
painter->drawText( rect, Qt::AlignCenter, tr("Qt by Nokia") ); //for example
}
};
But i get errors:
..\Calendar_forum_v2\/customcalendarwidget.h: In member function 'virtual void CustomCalendarWidget::paintCell(QPainter*, const QRect&, const QDate&) const':
..\Calendar_forum_v2\/customcalendarwidget.h:17: error: invalid use of incomplete type 'struct QPainter'
..\..\..\NokiaQtSDK\Simulator\Qt\mingw\include/QtGui/qwindowdefs.h:68: error: forward declaration of 'struct QPainter'
..\Calendar_forum_v2\/customcalendarwidget.h:18: error: invalid use of incomplete type 'struct QPainter'
..\..\..\NokiaQtSDK\Simulator\Qt\mingw\include/QtGui/qwindowdefs.h:68: error: forward declaration of 'struct QPainter'
Could someone please explain to me - what am I doing wrong?
class CustomCalendarWidget : public QCalendarWidget
{
Q_OBJECT
public:
CustomCalendarWidget( QWidget* parent = 0 ) : QCalendarWidget( parent ) {}
~CustomCalendarWidget() {}
protected:
virtual void paintCell( QPainter* painter, const QRect& rect, const QDate& date ) const
{
painter->setPen( Qt::black );
painter->drawText( rect, Qt::AlignCenter, tr("Qt by Nokia") ); //for example
}
};
But i get errors:
..\Calendar_forum_v2\/customcalendarwidget.h: In member function 'virtual void CustomCalendarWidget::paintCell(QPainter*, const QRect&, const QDate&) const':
..\Calendar_forum_v2\/customcalendarwidget.h:17: error: invalid use of incomplete type 'struct QPainter'
..\..\..\NokiaQtSDK\Simulator\Qt\mingw\include/QtGui/qwindowdefs.h:68: error: forward declaration of 'struct QPainter'
..\Calendar_forum_v2\/customcalendarwidget.h:18: error: invalid use of incomplete type 'struct QPainter'
..\..\..\NokiaQtSDK\Simulator\Qt\mingw\include/QtGui/qwindowdefs.h:68: error: forward declaration of 'struct QPainter'
Could someone please explain to me - what am I doing wrong?