QObject::connect(ui.pushButton_8, &QPushButton::pressed, [this]() {
QString str = ui.lineEdit_4->text();
str = str.trimmed();
if (!str.isEmpty())
{
QDateTime datetime = QDateTime::fromString(str, "yyyy-MM-dd hh:mm:ss");
ui.dateTimeEdit->setDateTime(datetime);
}
});
//设置日期dateEdit
QObject::connect(ui.pushButton_7, &QPushButton::pressed, [this]() {
QString str = ui.lineEdit_3->text();
str = str.trimmed();
if (!str.isEmpty())
{
QDateTime datetime = QDateTime::fromString(str, "yyyy-MM-dd");
ui.dateEdit->setDateTime(datetime);
}
});
//设置时间timeEdit
QObject::connect(ui.pushButton_6, &QPushButton::pressed, [this]() {
QString str = ui.lineEdit_2->text();
str = str.trimmed();
if (!str.isEmpty())
{
QDateTime datetime = QDateTime::fromString(str, "hh:mm:ss");
ui.timeEdit->setDateTime(datetime);
}
});