How to design a class like QTimer ?
-
As the question of title ,now I want to design a class ,the class has the effent such as the class of QTimer in Qt, user can use the class to decide when to start and when to stop ,and decide how long has passed between start and end ?
-
If I am getting your question right. I think you need to have a timer inside you class. That timer will be keep running infinite with a configurable interval. After each tick it will observe a start/end command from its user class. So your new class will be observing the commands from user class.
In other way, you can have a start timer (literally) in your new class. EXPLAINATION:
Your new class will accept a DATETIME in constructor and the internal timer of your new class will keep obsering that the current date time = DATETIME supplied. If yes then it will invoke some functionality.,, I hope its helpful, huff huff
-
[quote author="Yogesh" date="1331881509"]If I am getting your question right. I think you need to have a timer inside you class. That timer will be keep running infinite with a configurable interval. After each tick it will observe a start/end command from its user class. So your new class will be observing the commands from user class.
In other way, you can have a start timer (literally) in your new class. EXPLAINATION:
Your new class will accept a DATETIME in constructor and the internal timer of your new class will keep obsering that the current date time = DATETIME supplied. If yes then it will invoke some functionality.,, I hope its helpful, huff huff[/quote]
It‘s kind of you,you see,you help me a lot~~