Hi, I need a widget to countdown - to display it over a webcam display, before I capture a photo. Have you seen anything alike?
Hi, I need a widget to countdown - to display it over a webcam display, before I capture a photo. Have you seen anything alike?
Count down what? Have you seen QLCDNumber?
To countdown, you know, like before a rocket launch
I've seen the QLCDNumber and other standard Qt widgets. The question was if somebody has seen a widget meant precisely for countdown - it's all about reusability, isn't it?
Hmm... what's wrong with QLCDNumber? Reusability means exactly that you should reuse an existing component for different tasks, not that you should look if someone already had a similar problem...
If somebody had a similar problem, and solved it, then a component doing a nice countdown already exists... and I would like to reuse it
The thing with QLCDNumber is that it only displays a number. And I need to do an animation, like 3... 2... 1... boom - with a good timing and possibly some sound in parallel. Moreover, I'm not so sure if I would like to use an LCD-look.
Ok, tell me what do you want then, and I'll give you code that does what you want. Satisfied?
No no... It's not what I meant. I'll wait a couple of days and if I see that nobody had prepared such a widget before, I'll do it myself.
I wouldn't ask anybody to do my job for me - I only wander if I could reuse something somebody has already done for himself before. Isn't this forum a place of such exchange among developers using Qt? (I'm asking this question because from your posts, Wysota, I get an impression that I did something strange here...)
Long story short - you won't get a "countdown widget" from anyone, because if someone needed it, he would use QLCDNumber or QLabel with a QTimer - ten lines of code total (twenty if you want a more capable version). And that's exactly what I call code reuse - you use QLCDNumber or QLabel for different things.
Even shorter - you are wasting your time waiting a week for something you would acomplish yourself in 5 minutes.
You think I was doing nothing but waiting? It's just my idle time - looking at this forum
Thanks for your opinion, anyway. It's curious, though, how you can answer in the name of all Qt users...
If you hang out here for two years, you'll know why...
Here is the promised implementation, you can base on it to create your own:
Qt Code:
Q_OBJECT public: public slots: void start(int val=-1){ if(val>=0) display(val); m_id = startTimer(1000); } void stop(){ killTimer(m_id);} signals: void timeout(); protected: display(value()-1); if(value()<=0){ killTimer(m_id); m_id = -1; display(0); emit timeout(); return;} } };To copy to clipboard, switch view to plain text mode
anarsynd (20th November 2007)
Thanks for the code - I'll build on it :-)
And for the sound part? What would you use to play a wave file each time the displayed number changes?
Then I guess I know all I need. Thanks.
Bookmarks