QDate myBirthday(1989, 2, 28); // February 28th, 1989 myBirthday = myBirthday.addYears(10); // Adds 10 years to the date qDebug() << myBirthday.toString(); // Output: "Tue Feb 28 1999"
QDate graduationDate(2022, 5, 15); // May 15th, 2022 graduationDate = graduationDate.addYears(-1); // Subtracts 1 year from the date qDebug() << graduationDate.toString(); // Output: "Sun May 15 2021"In this example, the addYears() function is used to subtract 1 year from the date stored in the `graduationDate` object. The resulting date is then printed to the console using the `toString()` function. The QDate class and its member functions are part of the Qt Core library, which is included in the Qt framework.