关系转换

一、时间转换(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

你可能感兴趣的:(关系转换)