Results 1 to 10 of 10

Thread: Date and hours

  1. #1
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Date and hours

    Hj,

    I have a question how to do:

    in the notepad (xp) i click F5 and the date and hours appear..

    Kjiu

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Date and hours

    Do you mean : How to respond to a keyPressEvent, get the current time, format it into a string, and fill a textedit?

  3. #3
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Date and hours

    in the menu but the F5 (Shortcut)

    like I press the F5 or a go to menu and selected, and the hour and date will be on textedit

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Date and hours

    So you want to know how to put the date and time into a text edit from a menu press/QAction? Or just date and hour?

  5. #5
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Date and hours

    So you want to know how to put the date and time into a text edit from a menu press/QAction?
    Yes, can you can me how to do it.

  6. #6
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Date and hours

    hi

    You get the current time/date by using: QDateTime::currentDateTime(). This class has a toString(format) method, too. Format is also a string, like ("dd.MM.YYYY/hh.mm.ss")
    -> you get 13.11.2009/08.04.20
    This string you can set in the textEdit field.

  7. #7
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Date and hours

    like this ?

    Qt Code:
    1. public void date()
    2. {
    3. DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    4. java.util.Date date = new java.util.Date();
    5. String datetime = dateFormat.format(date);
    6. this.editor.insertPlainText(datetime);
    7. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Date and hours

    now I haven't errors but when I click on date it doesn't appear at editor

    Qt Code:
    1. public void date()
    2. {
    3. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    4. java.util.Date date = new java.util.Date();
    5. String datetime = dateFormat.format(date);
    6. this.editor.insertPlainText(datetime);
    7. }
    To copy to clipboard, switch view to plain text mode 

  9. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Date and hours

    Your using QtScript?

  10. #10
    Join Date
    Feb 2009
    Posts
    25
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Date and hours

    no, I am using QT Jambi

Similar Threads

  1. time and date issues
    By boog07005 in forum Newbie
    Replies: 5
    Last Post: 20th August 2012, 15:15
  2. sqlite and date
    By Raccoon29 in forum General Programming
    Replies: 2
    Last Post: 18th August 2008, 11:43

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.