You will need to use
qint64 QDateTime::toMSecsSinceEpoch () const
Returns the date and time as milliseconds since 1970-01-01 00: 00: 00.000
Since there is no way to directly find timeSpan. Convert 2 dateTime objects to milliseconds, subtract and convert them to days, hours, minutes, seconds using mathematical manipulation.
source share