#include// Current date and time QDateTime current = QDateTime::currentDateTime(); // Adding 5 days to the current date QDateTime future = current.addDays(5);
#includeIn both examples, we are using the addDays function to modify the date and time stored in a QDateTime object. The function returns a new QDateTime object with the modified date and time. The addDays function takes an integer argument which represents the number of days to add or subtract from the current date. The QDateTime class is part of the Qt library, which is a cross-platform application framework for developing desktop and mobile applications.// Current date and time QDateTime current = QDateTime::currentDateTime(); // Subtracting 3 days from the current date QDateTime past = current.addDays(-3);