1、拖个dateTimeEdit在界面上,同时来判断输入的时间的最后一天的日期是什么?
int year,month;int monthArr[12]={31,28,31,30,31,30,31,31,30,31,30,31};QDateTime time = ui->dateTimeEdit->dateTime();year = time.toString("yyyy").toInt();QStringList timeSplit = time.toString("yyyy-MM").split("-");month = timeSplit.at(1).toInt();qDebug()<<"month=="<<month;if((year%400==0)&&(year%4==0||year%100==0)){monthArr[1]=29;}for(int i = 0;i < 12; i++){if(month==(i+1)){qDebug()<<month<<"月有"<<monthArr[i]<<"天"<<endl;QString lastTime =time.toString("yyyy-MM")+QString("-")+QString::number(monthArr[i])+QString(" 23:59:59");qDebug()<<"lastTime=="<<lastTime;}}