Results 1 to 2 of 2

Thread: Qt QLCDNumber QTimer Digital Clock

  1. #1

    Default Qt QLCDNumber QTimer Digital Clock

    I am trying to create a digital clock. However, my purpose is not getting the currentTime(). Instead, I am defining my own time and incrementing the time from there onwards.

    However, in my codes, I am able to call tickSimulation(), but the clock timer won't start ticking. It just stuck at 11:00:00. Is adding addMSecs(1000) the correct way to increment the time?

    Please help. Thanks!

    Qt Code:
    1. StatusBar::StatusBar()
    2. {
    3. createButtons();
    4. time = new QTime(11, 0, 0);
    5. };
    6.  
    7. void StatusBar::createButtons()
    8. {
    9. ...
    10. lcdSimulation = new QLCDNumber;
    11. lcdSimulation->setNumDigits(8);
    12. simulationTimer = new QTimer;
    13. simulationTimer->start(1000);
    14. QObject::connect(simulationTimer, SIGNAL(timeout()), this, SLOT(tickSimulation()));
    15. addWidget(lcdSimulation);
    16. ...
    17. }
    18.  
    19. void StatusBar::tickSimulation()
    20. {
    21. QString text = time->toString(Qt::TextDate);
    22. lcdSimulation->display(text);
    23. time->addMSecs(1000);
    24. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,521
    Thanked 278 Times in 273 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt QLCDNumber QTimer Digital Clock

    Line 23 should be :
    Qt Code:
    1. time = time->addMSecs(1000);
    To copy to clipboard, switch view to plain text mode 
    Carefully read the description of the method QTime::addMSecs

Similar Threads

  1. Replies: 4
    Last Post: 18th December 2013, 21:02
  2. Digital Compass difficulty
    By Badeand in forum Newbie
    Replies: 1
    Last Post: 16th June 2011, 13:50
  3. OpenSSL and RSA :: digital signature
    By josecarlosmissias in forum Qt Programming
    Replies: 5
    Last Post: 7th May 2010, 15:23
  4. Digital Signing
    By DiamonDogX in forum Qt Programming
    Replies: 4
    Last Post: 21st May 2009, 23:09
  5. Using QT for Digital TV menu system?
    By mittalpa in forum Newbie
    Replies: 4
    Last Post: 2nd July 2008, 20:23

Tags for this Thread

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.