Results 1 to 10 of 10

Thread: date time to qtextedit??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: date time to qtextedit??

    Ok... is this?

    Qt Code:
    1. //we already have a QDateTimeEdit called "myDateTimeEdit"
    2. QDateTime datetime = QDateTime::currentDateTime();
    3. myDateTimeEdit.setDateTime(datetime);
    To copy to clipboard, switch view to plain text mode 

    the point I don't understand is a "QDateTimeEdit into a QTextEdit"

  2. The following user says thank you to jano_alex_es for this useful post:

    briang (16th October 2009)

  3. #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: date time to qtextedit??

    This might be what you are after:
    Qt Code:
    1. // get the value from the edit
    2. QDateTime dateTime = dateTimeEdit.dateTime;
    3. // format with the same format as the date time edit
    4. QString timeDateString = dateTime.toString(dateTimeEdit.displayFormat());
    5. // do stuff with the time/date string
    6. ...
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to ChrisW67 for this useful post:

    briang (16th October 2009)

  5. #3
    Join Date
    Oct 2009
    Location
    tathra nsw australia
    Posts
    14
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: date time to qtextedit??

    G'day Jano and Chris

    YES that is exactly what i was after

    QDateTime datetime1 = QDateTime::currentDateTime(); //sets QDateTimeEdit to today.
    dateTimeEdit->setDateTime(datetime1);

    QDateTime datetime2 = dateTimeEdit->dateTime(); //prints QDateTimeEdit to textEdit
    QString timeDateString = datetime2.toString(dateTimeEdit->displayFormat());
    textEdit->append(timeDateString); |
    Chris you show a full stop here but when i press fullstop i get this automatically.
    i did not know this to till now.

    At the moment i am just trying out how the various widgets interconnect.
    am now going to attack QTable ect.

    using Qt Creator 1.2.1 Qt4.5.2 (64bit) on kde4.3.1

    THANK YOU THANK YOU both

    Qt Creator is the ants pants.

    regards to you both
    Brian.

Similar Threads

  1. time and date issues
    By boog07005 in forum Newbie
    Replies: 5
    Last Post: 20th August 2012, 15:15
  2. QTextEdit loading takes long time
    By sreedhar in forum Qt Programming
    Replies: 12
    Last Post: 21st March 2011, 10:29
  3. How to change the date and time of a system
    By augusbas in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2009, 05:55
  4. automatic time and date updating
    By sudheer in forum Qt Tools
    Replies: 1
    Last Post: 17th January 2008, 10:00
  5. to set date and time in the file info of two days back
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2007, 16:54

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.