tags:

views:

58

answers:

1

Hello,

I am using a QCalendarWidget in my application, and I overloaded the updateCells method to put a red background on every dates which meet certain conditions.

My problem is I don't know how to get the first date displayed in the calendar (not the first date in the month), and the last date displayed. Example: in february, the first date displayed is january the 25th, and the last date displayed is march the 7th.

There isn't any useful method in QCalendarWidget and I can't think of an algorithm for this. Do you have any idea how to do this ?

+1  A: 

As you've got access to the currently shown month and year, you can use the QDate::dayOfWeek on the first and last date of the shown contents. Taking QCalendarWidget::firstDayOfWeek into account, you aught to be able to decide how far back and forth you have to go.

e8johan