emp1953
20th March 2020, 18:31
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:
QDateTime fdate = QFileInfo(file).lastModified();
QString sdate = fdate.toString("mm/dd/yyyy");
qDebug() << sdate;
QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("")
.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
I added the lines:
QDateTime fdate = QFileInfo(file).lastModified();
QString sdate = fdate.toString("mm/dd/yyyy");
qDebug() << sdate;
QTableWidgetItem *fileNameItem = new QTableWidgetItem(files[i]);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("")
.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