QDateTimeEdit及QDateTime的使用
QString strYear = ui->dateTimeEdit->sectionText(QDateTimeEdit::YearSection); QString strMonth = ui->dateTimeEdit->sectionText(QDateTimeEdit::MonthSection); QString strDay = ui->dateTimeEdit->sectionText(QDateTimeEdit::DaySection); QString strHour = ui->dateTimeEdit->sectionText(QDateTimeEdit::HourSection); QString strMinute = ui->dateTimeEdit->sectionText(QDateTimeEdit::MinuteSection); QString strSecond = ui->dateTimeEdit->sectionText(QDateTimeEdit::SecondSection); QString strTime = ui->dateTimeEdit->dateTime().toString("yyyy-MM-dd HH:mm:ss"); m_dtStart = QDateTime::fromString("2021-09-17 00:11:00", "yyyy-MM-dd HH:mm:ss"); m_dtStart = ui->dateTimeEdit->dateTime(); //时间增加秒 QString MainWindow::GetTimeStr(int addSecs) { QDateTime dtFinal = m_dtStart.addSecs(addSecs); QString ret = dtFinal.toString("yyyy-MM-dd HH:mm:ss"); return ret; }
标签:QDateTimeEdit,dateTimeEdit,ss,ui,QString,使用,sectionText From: https://www.cnblogs.com/warmlight/p/17079703.html