English Български
Customizing the appearance of QCalendarWidget
There are numerous ways to make a calendar. And the simplest one , must be using the QCalendarWidget [doc.qt.nokia.com]. However, we have limited control over the appearance of this widget.
Inheriting the QCalendarWidget [doc.qt.nokia.com] can solve the issue. Here is the example class which explains a ‘custom’ calendar widget.
The cells, or the particular days are customized, and in order to do this , we need to take control over the protected function paintCell [doc.qt.nokia.com]
Example:
- {
- Q_OBJECT
- public:
- ~ourCalendarWidget() {}
- {
- // here we set some conditions
- update();
- }
- protected:
- {
- if ( ) // our conditions
- { // When the conditions are matched, passed QDate is drawn as we like.
- painter->save();
- painter->drawEllipse(rect); // here we draw n ellipse and the day--
- painter->restore();
- }
- else
- { // if our conditions are not matching, show the default way.
- }
- }
That is all. Happy coding.

