How to update the current day of MonthGrid?
-
Hello guys,
It is recommended to use the MonthGrid to implement a calendar or date picker in Qt6's document.
I tried; it works generally. User can pick any date from the MonthGrid. But if change the system's date according to user's pick, the current day of MonthGrid is not changed.
You know MonthGrid only has 'year' and 'month' properties, doesn't have a 'day' property. The only way is rewrite the delegate of MonthGrid, model has the 'day' property. But how to update the delegate?
Borrow a picture from @Antonio Ortiz.MonthGrid wrong current index . Not related to this topic, just to make this post beautiful. Thanks.
-
@Hit-Tiger-Tonight
Here is a workaround:
Once system time changed, call this function:function refreshYourMonthGrid() { theIDofYourMonthGrid.year++ theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear() }
Even simpler:
function refreshYourMonthGrid() { theIDofYourMonthGrid.year++ theIDofYourMonthGrid.year-- }
-
Hello guys,
It is recommended to use the MonthGrid to implement a calendar or date picker in Qt6's document.
I tried; it works generally. User can pick any date from the MonthGrid. But if change the system's date according to user's pick, the current day of MonthGrid is not changed.
You know MonthGrid only has 'year' and 'month' properties, doesn't have a 'day' property. The only way is rewrite the delegate of MonthGrid, model has the 'day' property. But how to update the delegate?
Borrow a picture from @Antonio Ortiz.MonthGrid wrong current index . Not related to this topic, just to make this post beautiful. Thanks.
@Hit-Tiger-Tonight
Here is a workaround:
Once system time changed, call this function:function refreshYourMonthGrid() { theIDofYourMonthGrid.year++ theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear() }
-
@Hit-Tiger-Tonight
Here is a workaround:
Once system time changed, call this function:function refreshYourMonthGrid() { theIDofYourMonthGrid.year++ theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear() }
Even simpler:
function refreshYourMonthGrid() { theIDofYourMonthGrid.year++ theIDofYourMonthGrid.year-- }
-
-