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