Results 1 to 5 of 5

Thread: How to show the seconds in the digital clock using QLcd Number??

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to show the seconds in the digital clock using QLcd Number??

    Qt Code:
    1. QTime time = QTime::currentTime();
    2. QString text = time.toString("hh:mm:ss");
    3. if ((time.second() % 2) == 0)
    4. text[2] = ' ';
    5. ui->lcdNumber->display(text);
    To copy to clipboard, switch view to plain text mode 

    Am using the code above: Its not displaying the hour,minute and the second together
    please help me

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to show the seconds in the digital clock using QLcd Number??

    One QLCDNumber can show one number (int or double) so you must crate a QLCDNumber for each (hour, minute, second) and show them in a QHBoxLayout (or whatever is appropriate for your application)

  3. The following 2 users say thank you to Zlatomir for this useful post:


  4. #3
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to show the seconds in the digital clock using QLcd Number??

    Hi Gokulnathvc,

    From the QLCDNumber documentation I see that
    If the displayed value is not a number, the property has a value of 0.
    .
    So I don't believe that you can achive what you want only by using one QLCDNumber. Maybe try using 3 objects, one for the hours, one for minutes, and one for seconds.

    Regards,
    Wladek
    Last edited by wladek; 23rd March 2011 at 12:50. Reason: Zlatomir was quicker :)
    One second is long, everything longer than two seconds is definitely too long.

  5. The following 2 users say thank you to wladek for this useful post:


  6. #4
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to show the seconds in the digital clock using QLcd Number??

    Qt Code:
    1. QTime time = QTime::currentTime();
    2. QString text = time.toString("hh:mm");
    3. QString text1=time.toString("ss");
    4. ui->lcdNumber->display(text+":"+text1);
    To copy to clipboard, switch view to plain text mode 

    This works very fine...

  7. The following 2 users say thank you to Gokulnathvc for this useful post:


  8. #5
    Join Date
    Apr 2011
    Posts
    19
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: How to show the seconds in the digital clock using QLcd Number??

    I was trying to do the same thing a you and I would guess you need to change the number of digits the LCD will show. Somewhere you need to do

    Qt Code:
    1. setDigitCount(8);
    To copy to clipboard, switch view to plain text mode 

    The default number of digits for the LCD display is 5.

  9. The following 3 users say thank you to mechsin for this useful post:

    Zlatomir (19th December 2013)

Similar Threads

  1. Digital Signing
    By DiamonDogX in forum Qt Programming
    Replies: 4
    Last Post: 21st May 2009, 22:09
  2. qdirmodel question: show file number of a folder?
    By zl2k in forum Qt Programming
    Replies: 3
    Last Post: 7th November 2008, 07:07
  3. Replies: 4
    Last Post: 22nd August 2008, 10:08
  4. Using QT for Digital TV menu system?
    By mittalpa in forum Newbie
    Replies: 4
    Last Post: 2nd July 2008, 19:23
  5. How to trap an QLCD overflow?
    By jamadagni in forum Qt Programming
    Replies: 1
    Last Post: 17th February 2006, 08:18

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.