1、界面上拖动两个QDateTimeEdit控件,同时设置为开始时间与结束时间,然后再来拖动个pushButton,命名为查询功能,然后槽函数中,实现如下:
void Database::on_pushButton_4_clicked()
{QDateTime time1 = ui->dateTimeEdit->dateTime();QDateTime time2 = ui->dateTimeEdit_2->dateTime();int days = time1.daysTo(time2);for(int i = 1; i <= days; i++){QDateTime nextWeek = time1.addDays(i);qDebug()<<"nextWeek=="<<nextWeek.toString("yyyy-MM-dd");}qDebug() << "time2 - time1=" << days ;
}