Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一个优雅的 C++ 函数,它接受一个包含 unix 时间(例如 1295874681)的 QString 参数并将其转换为包含 QString 的标准时间格式(例如周一,2011 年 1 月 24 日 13:11:21 GMT)并返回它。
bool ok; const uint s = unixTimeStr.toUInt( &ok ); if ( !ok ) { ..handle conversion error (unixTimeStr not containing a number) } const QDateTime dt = QDateTime::fromTime_t( s ); const QString textdate = dt.toString( Qt::TextDate );