How to add some days/months to date edit object to get next date?

Viewed 164

I have a dateedit widget and I am getting date from that dateedit widget

temp_var = self.dateEdit.date() 
print(temp_var)
var_name = temp_var.toPyDate()
print(var_name)

this prints,

PyQt5.QtCore.QDate(2021, 04, 16)
2021-04-16

If I wanted to find next date 9 months and 9 days ahead of this date obtained from dateedit object and set another dateedit object, how can we do that?

1 Answers

QDate offers methods to add months and days:

days = 9
months = 9

dt = self.dateEdit.date().addMonths(months).addDays(days)

print(dt, dt.toPyDate())
Related