Results 1 to 3 of 3

Thread: [SOLVED] QDate is giving a different date

  1. #1
    Join Date
    Nov 2010
    Location
    planet earth
    Posts
    19
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default [SOLVED] QDate is giving a different date

    hi,

    i have a weird problem regarding on QDate. this is the code :

    Qt Code:
    1. QString strDate = "April 01, 1981";
    2. QDate date = QDate::fromString(strDate);
    To copy to clipboard, switch view to plain text mode 

    when i tried to display it again using date.toString("MMMM dd yyyy") = September 14 1752. what happened to my date?
    Last edited by xeroblast; 7th December 2010 at 04:01.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QDate is giving a different date

    The conversion failed. You are telling QDate::fromString() to use the format Qt::TextDate but feeding in a date that is not in that format. You want to adjust your string format, or use the other variant of the fromString() method and specify how the string should be interpreted.

  3. #3
    Join Date
    Nov 2010
    Location
    planet earth
    Posts
    19
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDate is giving a different date

    yeah.. thanx for the reply. it should be : QDate date = QDate::fromString(strDate, "MMMM dd, yyyy"). the Qt::TextDate must be the correct format of the string date.

Similar Threads

  1. Giving reference to QThread
    By codeman in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2010, 10:33
  2. OpenCASCADE sample for qt is giving problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 1st December 2009, 10:02
  3. giving main window a name?
    By oji in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2009, 11:13
  4. How to default Date-Edit Widget to system date
    By JohnToddSr in forum Qt Tools
    Replies: 4
    Last Post: 17th January 2007, 19:18
  5. QFontMetrics not giving proper dimension
    By Gopala Krishna in forum Qt Programming
    Replies: 3
    Last Post: 7th October 2006, 15:00

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.