我得到的日期格式如下:“2011-04-14 15:00:00”,并希望将它们设置为QDateTimeEdit对象。
我就是这样做的:
void MainWindow::setUIDateAndTime(QString &date)
{
QDateTime dateTime;
dateTime.fromString(date, "yyyy-MM-dd hh:mm:ss");
QString sDatetime = dateTime.toString("yyyy-MM-dd hh:mm:ss"); // For debug testing
// Create the datetime picker
QDateTimeEdit *dateTimePicker = new QDateTimeEdit(dateTime);
dateTimePicker->setObjectName("dateTimePicker");
ui->frameCommentHolderLayout->addWidget(dateTimePicker);
}
But it never get s set. The debug variable "sDateTime" is always set to "".
Does Anybody see what i do wrong? Thanks in advance.