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
QCalendarWidget
and reimplementvoid QCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const
method.So let's create a
Calendar
class in the Calendar.h:Implement this class in Calendar.cpp:
And after that if you're using Qt Creator, you can add
QCalendarWidget
from the left bar to your widget, right click on it and open Promote to menu. AddCalendar
to Promoted class name and check that Header file is correct. Hit Add to addCalendar
to the promoted classes list and finally hit Promote to turn theQCalendarWidget
on your form into aCalendar
.After that I get the following widget (sorry for Russian):