Results 1 to 12 of 12

Thread: QDateTime problem

  1. #1
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Red face QDateTime problem

    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
    Qt Code:
    1. QFileInfo MyFile(FilePath);
    2. qDebug() << MyFile.lastModified().toString("YYYY-MM-DDTHH:MM:SS");
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem


  3. #3
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    Qt Code:
    1. qDebug() <<MyFile.lastModified().toString("ddd MMMM d yy");
    To copy to clipboard, switch view to plain text mode 

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

  4. #4
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    Coud the date be invalid?

  5. #5
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    sorry but I did not understand what you mean , can you write example

    thanks

  6. #6
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    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 !

  7. #7
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    Think is good, but check is better. What does this write:

    Qt Code:
    1. qDebug() <<MyFile.lastModified().isValid();
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    its output false !!!

    but way !?

    Qt Code:
    1. qDebug() <<MyFile.fileName()
    2. qDebug() <<MyFile.lastModified().isValid();
    To copy to clipboard, switch view to plain text mode 

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

  9. #9
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    What about:

    Qt Code:
    1. qDebug() <<MyFile.exists();
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    return false

  11. #11
    Join Date
    Jan 2006
    Posts
    132
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    Case solved, right?

  12. #12
    Join Date
    Nov 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateTime problem

    yes sir, sorry for disturbance


Similar Threads

  1. deployment problem: msvc++ 2008 Express, Qt 4.4.3
    By vonCZ in forum Qt Programming
    Replies: 7
    Last Post: 10th November 2008, 14:38
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Problem with comparing two QDateTime objects
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2008, 11:27
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.