2016-12-25 333 views
0

我有日期線數字,我如何將這些數字轉換爲qml中的時間字符串?這是我所嘗試過的,但得到了錯誤,committedDate是int數,它持有從紀元開始的毫秒數。將QML中的dateline數字轉換爲時間字符串

Text { 
    id: timeText 
    anchors.centerIn: parent 
    text: Date(committedDate).toTimeString() 
    color: "white" 
} 

誤差

qrc:/Conversation.qml:1940: TypeError: Property 'toTimeString' of object Sun Dec 25 11:08:45 2016 GMT+0330 is not a function

回答

1

中有Qt對象/命名空間日期格式化選項:

Qt.formatDate() 
Qt.formatDateTime() 
Qt.formatTime() 

例如

text: Qt.formatDateTime(Date(milliseconds), Qt.ISODate)