1、QDateTime 转换为 QString
QString strBuffer;
QDateTime time;
time = QDateTime::currentDateTime();
strBuffer = time.toString("yyyy-MM-dd hh:mm:ss");
// strBuffer = 2010-07-02 17:35:00
2、QString 转换为 QDateTime
QString strBuffer;
QDateTime time;
strBuffer = "2010-07-02 17:35:00";
time = QDateTime::fromString(strBuffer, "yyyy-MM-dd hh:mm:ss");
本文介绍了如何在Qt中将QDateTime类型的数据转换为QString类型,以及如何将QString类型的时间字符串转换回QDateTime类型。这两种转换对于处理日期和时间数据非常实用。
3116

被折叠的 条评论
为什么被折叠?



