PDA

View Full Version : How to show the seconds in the digital clock using QLcd Number??



Gokulnathvc
23rd March 2011, 12:22
QTime time = QTime::currentTime();
QString text = time.toString("hh:mm:ss");
if ((time.second() % 2) == 0)
text[2] = ' ';
ui->lcdNumber->display(text);

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

Zlatomir
23rd March 2011, 12:49
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)

wladek
23rd March 2011, 12:50
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

Gokulnathvc
1st April 2011, 09:14
QTime time = QTime::currentTime();
QString text = time.toString("hh:mm");
QString text1=time.toString("ss");
ui->lcdNumber->display(text+":"+text1);

This works very fine...

mechsin
18th December 2013, 20:02
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


setDigitCount(8);

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