1、QDateTime 转换为 QString
QString QDateTime::toString ( Qt::DateFormat format = Qt::TextDate ) const
- 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
QDateTime QDateTime::fromString ( const QString & string, const QString & format )
- QString
strBuffer; - QDateTime
time; -
- strBuffer
= "2010-07-02 17:35:00"; -
- time
= QDateTime::fromString(strBuffer, "yyyy-MM-dd hh:mm:ss");
本文介绍了如何在Qt中将QString转换为QDateTime,以及如何从QDateTime获取QString。通过实例演示了两种日期时间格式之间的转换过程。
7603

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



