PDA

View Full Version : Need to make QLCDNumber display count up/down



JimDaniel
29th September 2007, 01:15
Hi, I need to be able to set my QLCDNumber to a new value and have it count up or count down to that new value on screen.

Is the best way to do that by connecting the new value to an invisible QSlider first, then connecting the slider value to the QLCDNumber? Or is there a more direct way?

Thanks for any help you can give!

wysota
29th September 2007, 01:37
How about:

class X : public QLCDNumber {
public:
X(...) : ... {...}
void countFrom(int tim){
left = tim;
startTimer(1000);
display(left);
}
protected:
void timerEvent(QTimerEvent *e){
if(--left==0)
killTimer(e->timerId());
display(left);
}
private:
int left;
};

JimDaniel
29th September 2007, 01:59
Nice solution. Thanks for that!