用Qt写的倒计时程序,可根据指定时间作不同用途。创建Qt的简单GUI工程,修改main.cpp即可。
#include <QApplication>
#include <QLabel>
#include <QDate>
#include <QLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel *label = new QLabel;
QDate currentDate = QDate::currentDate();
QDate kaoyanri(2015,1,7);
qint64 tianshui = currentDate.daysTo(kaoyanri);
QString tianshu = QString::number(tianshui);
QString string("离考研还有<font color='red';><b>");
QString tian("</b></font>天");
string = string + tianshu + tian;
label->setText(string);
label->setWindowTitle("考研倒计时");
QFont font;
font.setPointSize(30);
label->setFont(font);
label->resize(300,43);
label->show();
return a.exec();
}