Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7502781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:59:18+00:00 2026-05-29T20:59:18+00:00

So, I found something working here, and I wish to understand how it works.

  • 0

So, I found something working here, and I wish to understand how it works.

#ifndef  LCDNUMBER_H
#define LCDNUMBER_H

#include <QLCDNumber>
#include <QTimer>
#include <QTime>
#include <iostream>

class lcdDisplay : public QLCDNumber
{
    Q_OBJECT  

    public:
        // The QTimer class provides repetitive and single-shot timers.
        QTimer* objTimer;
        // The QTime class provides clock time functions.
        QTime*  objTime;

    public:
        lcdDisplay (QWidget *parentWidget, int minutes, int seconds)
        {
            objTimer = new QTimer ();
            // Setting our own time with the specified hours, minutes, and seconds.
            objTime  = new QTime  (0, minutes, seconds);

            setParent (parentWidget);

            // connect (objectA, signalAFromObjectA, objectB, slotAFromObjectB)
            // timeout (): This signal is emitted when the timer times out. The time out period can be specified with `start (int milliseconds)` function.
            QObject :: connect (objTimer, SIGNAL (timeout ()), this, SLOT (setDisplay ()));
        };

        ~ lcdDisplay () {};

    public slots:
        // This slot is called after the timer timeouts (1 second).
        void setDisplay ()
        {
            std::cout << "\nf,gfd,mgnfdm,gnf,\n";
            // 
            objTime->setHMS (0, objTime->addSecs (-1).minute (), objTime->addSecs (-1).second ());
            display (objTime->toString ());
        };
};
#endif

I wish to understand this line: objTime->setHMS (0, objTime->addSecs (-1).minute (), objTime->addSecs (-1).second ());

How does this decrease the minutes and seconds internally?
From here: http://doc.qt.nokia.com/4.7/qtime.html#addSecs

QTime n(14, 0, 0); // n == 14:00:00
QTime t;
t = n.addSecs(70); // t == 14:01:10
t = n.addSecs(-70); // t == 13:58:50

addSecs function perhaps adds or subtracts seconds. Fine. but does this do objTime->addSecs (-1).minute (),?

How does setHMS work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:59:19+00:00Added an answer on May 29, 2026 at 8:59 pm

    This code example by itself has no functionality to count down like a stop watch. Its currently a display only example to show the current time value. If what you want is to allow it to count down, I would recommend adding a QTimer to the class with a 1 second timeout. You connect the timeout to a slot that will subtract one second from your display time. When you start the internal timer it will fire every second. In your slot that does the subtracting you can stop the timer once your clock value reaches zero.

    update

    Your new edited example is exactly what I was describing here with this initial answer. The timer fires every second and calls a slot that adjusts the time object

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
I was working on a demo method and found something strange(at least to me
I found something surprising with std::vector that I thought I'd ask about here to
I just found something that sounds weird with Maven plugin management. While working on
I found the C snippet to get the current working directory from here .
I have been trying to understand and get something working with dependency properties. I
(I asked a similar question here and found a working solution under certain circumstances,
I've been messing around with HTML5 / Javascript and found something I don't understand.
I´m working with windowsapps, and I need to do something different here. I created
I have written/found a php script and I don't understand why it's working one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.