Help me please, my friends!I need to calendar widget look like this: desired calendar
But i have a problem. I only get this: my calendar
I need to do this: dates that are out of range (minimalDate, maximumDate) should be colored as inactive (main color for active dates is black, then for inactive dates is gray, for example). Sorry for my bad english:)
I'm trying to write like this:
/* activel days */
QCalendarWidget QAbstractItemView:enabled
{
font-size:24px;
color: rgb(180, 180, 180);
background-color: black;
selection-background-color: rgb(64, 64, 64);
selection-color: rgb(0, 255, 0);
}
/* days inactive */
QCalendarWidget QAbstractItemView:disabled { color: rgb(64, 64, 64); }
You should create your own custom calendar class derived from
QCalendarWidgetand reimplementvoid QCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) constmethod.So let's create a
Calendarclass in the Calendar.h:Implement this class in Calendar.cpp:
And after that if you're using Qt Creator, you can add
QCalendarWidgetfrom the left bar to your widget, right click on it and open Promote to menu. AddCalendarto Promoted class name and check that Header file is correct. Hit Add to addCalendarto the promoted classes list and finally hit Promote to turn theQCalendarWidgeton your form into aCalendar.After that I get the following widget (sorry for Russian):