1

I created a QCalendarWidget in my Gui. By default, if you change the month in the calendar NavigationBar, the day is not set to anything (i.e.: the user have to select it manually otherwise no day is set). I am trying to connect a signal that each time I change the month (i.e.: from June to May) the day is set from the current day to the first of that month (i.e.: from 12 to 1).

I already built the "connect function" using sinal: currentPageChanged(int, int) which is working fine. then, inside this slot, I am trying to update the day to become the 1st which is something I could do as there is no setDay() function !!

so, how can I set the 1st day of the selected month each time I change the current month in QCalendarWidget ?

4

1 回答 1

4

try inside your slot (assuming your QCalendarWidget is named calendar):

QDate date = calendar.selectedDate();
date.setDate(date.year(),date.month(),1);
calendar.setSelectedDate(date);
于 2013-06-12T16:03:34.330 回答