在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
没事,别怕,这是签名→→┃ 青山幽谷笛声扬,白鹤振羽任翱翔。往事前尘随风逝,携手云峰隐仙乡。 ┃