I need to set up a loop that increments a date between a startdate and enddate (both QDate variables). When I increment the loop variable dd using dd.addYears(1), dd does not change, hence the while loop runs for ever.
Why does the code below
dd
= startdate
( a
QDate variable
)while ( dd < enddate ) {
returnvalue = returnvalue + m_amount;
dd.addYears(1);
qstr.clear();
QTextStream(&qstr
) <<
"Weekday transaction of value " << returnvalue <<
" on " << dd.toString();
DebugMessage(qstr); // echos qstr to a log file
}
QDate dd;
dd= startdate ( a QDate variable)
while ( dd < enddate ) {
returnvalue = returnvalue + m_amount;
dd.addYears(1);
qstr.clear();
QTextStream(&qstr) << "Weekday transaction of value " << returnvalue <<
" on " << dd.toString();
DebugMessage(qstr); // echos qstr to a log file
}
To copy to clipboard, switch view to plain text mode
Give the following output for qstr;
Weekday transaction of value 1 on Wed Feb 25 2009
Weekday transaction of value 2 on Wed Feb 25 2009
Weekday transaction of value 3 on Wed Feb 25 2009
Weekday transaction of value 4 on Wed Feb 25 2009
Weekday transaction of value 5 on Wed Feb 25 2009
Weekday transaction of value 6 on Wed Feb 25 2009
Weekday transaction of value 7 on Wed Feb 25 2009
Weekday transaction of value 8 on Wed Feb 25 2009
Have I just done something stupid
Bookmarks