在QT中计算宝贝女生的年龄~

使用QT中<QDate>。

 

 

1 QDate birthday(2010,10,13);
2 QDate today;
3 today = QDate::currentDate ();
4 int daysold = birthday.daysTo (today);
5 ui->lcdNumber_2->display (daysold);

 

说明:

int QDate::daysTo ( const QDate & d ) const

Returns the number of days from this date to d (which is negative if d is earlier than this date).

 QDate d1(1995, 5, 17);  // May 17, 1995 
 QDate d2(1995, 5, 20);  // May 20, 1995 
 d1.daysTo(d2);          // returns 3 
 d2.daysTo(d1);          // returns -3

posted @ 2010-12-07 23:40  Delcpp  阅读(1068)  评论(0编辑  收藏  举报