How can I get the date out of QFileInfo?
I am using the find file dialog code at https://doc.qt.io/archives/qt-4.8/qt...s-example.html
I added the lines:
Code:
QString sdate
= fdate.
toString("mm/dd/yyyy");
qDebug() << sdate;
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
.arg(fdate.toString()));
QFileInfo(file).lastModified() gives the the following info:
Wed March 18 16:15:33 2020
Seems like kind of a jumbled way of providing a date time.
So I want just 03/18/2020 I feed it into QString sdate = fdate.toString("mm/dd/yyyy");
But this gives me "33/18/2020"
First How do I get the file info lastModified to appear as 03/18/2020?
Second I changed the declaration for sizeItem to:
QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("")
.arg(fdate.toString()));
I want the date to be printed out instead of the file size. File size is useless to my needs.
How can I accomplish that part?
Thanks to all
emp1953
Re: How can I get the date out of QFileInfo?
Because 'mm' are the minutes according the documentation: https://doc.qt.io/qt-5/qdatetime.html#toString
Re: How can I get the date out of QFileInfo?
Quote:
Second I changed the declaration for sizeItem to:
QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("").arg(fdate.toString()));
And didn't I tell you in reply to your last post (in the "General Discussion" section) how to properly format a QString().arg() expression?
We aren't going to write your code for you, and you have to read and understand the answers so you can write it yourself.