PDA

View Full Version : QDateTime problem



Majdi
28th January 2009, 14:20
Hi,
I'm writing software under windows
I'm trying to get the last Modified date for file and convert the return value to QDateTime


QFileInfo MyFile(FilePath);
qDebug() << MyFile.lastModified().toString("YYYY-MM-DDTHH:MM:SS");

but when i try to output the file name or suffix its work ... I think I have problem with converting for QDateTime , I search in the documentation but i did not find any useful example for me .. can anyone help ?

Thanks

seneca
28th January 2009, 14:49
Check your format string:

http://doc.trolltech.com/4.4/qdatetime.html#toString

Majdi
28th January 2009, 15:05
qDebug() <<MyFile.lastModified().toString("ddd MMMM d yy");

I saw that page and I already read it , even now i used the same format that exist in that page , no output !

seneca
28th January 2009, 15:11
Coud the date be invalid?

Majdi
28th January 2009, 15:16
sorry but I did not understand what you mean , can you write example

thanks

Majdi
28th January 2009, 15:21
I don't think so, because I bring the date from the file system

QDateTime QFileInfo::lastModified () const

so the return value will be type QDateTime
and also i used MyFile object to access other data such as file name and size , its output right data , which means the file object is point to file in right way ... so lastModified should return value of type QDateTime and I need to covert it to string ... but whatever i try its output nothing !

seneca
28th January 2009, 15:25
Think is good, but check is better. What does this write:


qDebug() <<MyFile.lastModified().isValid();

Majdi
28th January 2009, 15:31
its output false !!!

but way !?



qDebug() <<MyFile.fileName()
qDebug() <<MyFile.lastModified().isValid();


since its return the file name , why its dont return the last modified date !!! ?

seneca
28th January 2009, 15:39
What about:


qDebug() <<MyFile.exists();

Majdi
28th January 2009, 15:48
return false :crying::confused:

seneca
28th January 2009, 15:49
Case solved, right? ;)

Majdi
28th January 2009, 15:57
yes sir, sorry for disturbance

:o