首页 > 其他 > 详细

关系转换

时间:2019-12-18 15:26:04      阅读:102      评论:0      收藏:0      [点我收藏+]

一、时间转换(QDateTime、QString、time_t)

1、QDateTime转换为QString

QString strBuffer;
QDateTime time;
time = QDateTime::currentDateTime();
strBuffer = time.toString("yyyy-MM-dd hh:mm:ss");

2、QString转换为QDateTime

QString strBuffer;
QDateTime time;
strBuffer = "2018-06-06 14:05:00";
time = QDateTime::fromString(strBuffer, "yyyy-MM-dd hh:mm:ss");

3、QDateTime转换为time_t

time_t  curTime; 
QDateTime time; 
time = QDateTime::fromTime_t(curTime);

4、QDateTime转换为time_t

time_t  curTime; 
QDateTime time; 
curTime = time.toTime_t();

 

二、QModelIndex和QStandardItem

1、 QModelIndex 转换成QStandardItem

QStandardItem * item=QStandardItemModel::?itemFromIndex(const QModelIndex & index) const

2 、QStandardItem 转换成 QModelIndex

QModelIndex model = QStandardItem::?index() const

关系转换

原文:https://www.cnblogs.com/Jaime1106/p/11804221.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!