Results 1 to 3 of 3

Thread: Need to make QLCDNumber display count up/down

  1. #1
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Need to make QLCDNumber display count up/down

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need to make QLCDNumber display count up/down

    How about:
    Qt Code:
    1. class X : public QLCDNumber {
    2. public:
    3. X(...) : ... {...}
    4. void countFrom(int tim){
    5. left = tim;
    6. startTimer(1000);
    7. display(left);
    8. }
    9. protected:
    10. void timerEvent(QTimerEvent *e){
    11. if(--left==0)
    12. killTimer(e->timerId());
    13. display(left);
    14. }
    15. private:
    16. int left;
    17. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Need to make QLCDNumber display count up/down

    Nice solution. Thanks for that!

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57

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.