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 )   [static]

 

QString strBuffer;
QDateTime time;

strBuffer = "2010-07-02 17:35:00";

time = QDateTime::fromString(strBuffer, "yyyy-MM-dd hh:mm:ss");

 

posted on 2013-05-08 16:33  夜&枫  阅读(20529)  评论(0编辑  收藏  举报