Results 1 to 14 of 14

Thread: Time in textBrowser

  1. #1
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Time in textBrowser

    Hi
    I want to put the hours in qt creator.
    Then prints the time in the textBrowser.

    Thank

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    Quote Originally Posted by NewLegend View Post
    Hi
    I want to put the hours in qt creator.
    You can link to QUniverseCoreLib, it contains a pointer to QUniverseTime. Be aware that it is abstract. You need to subclass QUniverseTime to something like QEarthTime to make it more useful.

    Also note that linking to QUniverseCoreLibd (the debug version that is) might take a little bit more space (no pun intended).

    Then prints the time in the textBrowser.
    Use the classes QDateTime or QTime
    See their documentation. You might want to use the function toString(...)

    If you expected a better answer, I expected a better question.

  3. #3
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Will it be like this clock.png

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    I guess you want to have something like in the screenshot?

    Qt Code:
    1. QTextBrowser textBrowser;
    2. textBrowser.append(QTime::currentTime().toString("hh:mm:ss"));
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Quote Originally Posted by tbscope View Post
    I guess you want to have something like in the screenshot?

    Qt Code:
    1. QTextBrowser textBrowser;
    2. textBrowser.append(QTime::currentTime().toString("hh:mm:ss"));
    To copy to clipboard, switch view to plain text mode 
    Thank
    But I using qt creator.
    so, when using
    Qt Code:
    1. ui->textBrowser->append(QTime::currentTime().toString("hh:mm:ss"));
    To copy to clipboard, switch view to plain text mode 
    i see this error
    '.toString' must have class/struct
    'currentTime' identifier not found

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    Include QTime and QString

  7. #7
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Quote Originally Posted by tbscope View Post
    Include QTime and QString
    You are wonderful
    But How to Make a digital clock
    as, cll.png

    secend, Can I increase the clock time ??
    as,
    Qt Code:
    1. ui->textBrowser->append(QTime::currentTime().toString("hh:mm:ss") + "I want to increase a minute of time");
    To copy to clipboard, switch view to plain text mode 

    If the time is now 15:44:00
    I want to aggravated 15:45:00
    Last edited by NewLegend; 11th October 2010 at 13:45.

  8. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    Use a QTimer (note the difference with QTime).
    Set an interval (example: 1 second)
    Connect a slot to the timeout() signal
    in that slot, clear the contents of the textbox and set it to the current time.

  9. #9
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    What about Make a digital clock
    as, cll.png

    I can not use timeEdit
    Because it is Input not display.

  10. #10
    Join Date
    Jul 2010
    Posts
    71
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Quote Originally Posted by tbscope View Post
    Use a QTimer (note the difference with QTime).
    Set an interval (example: 1 second)
    Connect a slot to the timeout() signal
    in that slot, clear the contents of the textbox and set it to the current time.
    I want to increase the time is not decreased.

    If the time is now 15:44:00
    I want to see in textBrowser 15:45:00

  11. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    I suggest a good course in English if you want to do computer programming.

  12. #12
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Quote Originally Posted by tbscope View Post
    I suggest a good course in English if you want to do computer programming.


    ???????????????????

  13. #13
    Join Date
    Sep 2010
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Time in textBrowser

    Quote Originally Posted by NewLegend View Post
    secend, Can I increase the clock time ??
    as,
    Qt Code:
    1. ui->textBrowser->append(QTime::currentTime().toString("hh:mm:ss") + "I want to increase a minute of time");
    To copy to clipboard, switch view to plain text mode 

    If the time is now 15:44:00
    I want change to 15:45:00
    using
    Qt Code:
    1. ui->textBrowser->append( QTime::currentTime().addSecs(60).toString("hh:mm:ss") );
    To copy to clipboard, switch view to plain text mode 

  14. #14
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Time in textBrowser

    Quote Originally Posted by Jeneo W. View Post


    ???????????????????
    Maybe you don't know this, but most tools for creating software are in English and so is the documentation. Learn it to understand it. There's no point explaining it again in English if the person doesn't understand it.

Similar Threads

  1. space in textBrowser
    By NewLegend in forum Qt Programming
    Replies: 4
    Last Post: 3rd September 2010, 19:04
  2. New Line in textBrowser
    By NewLegend in forum Qt Programming
    Replies: 4
    Last Post: 12th August 2010, 05:29
  3. Showing picture on textbrowser
    By anafor2004 in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2008, 17:09
  4. Textbrowser issue
    By deekayt in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2006, 07:51
  5. How to display a file in the textBrowser
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 19:47

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.