Unsolved Put Video Timer without using Design
-
I am playing a video in Qt, I have a text box to enter the URL, Buttons to start and stop video.
I have not used the Design for any of above.
Can I get help on how to insert a timer which starts and stops on pressing the start and stop button respectively
-
@adityatrikha08 I don't know what you mean by "Design".
To start stop a timer see http://doc.qt.io/qt-5/qtimer.htmlQTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing())); timer->start(); ... // Later when stop button is clicked timer->stop();
-
@jsulm I guess that by "Design" @adityatrikha08 means "Qt Designer"
And I guess the idea is the opposite, the "timer" should start when the start button is pressed (the same button that starts video playing) and "timer" should stop when stop button is pressed.
If I'm right, then @adityatrikha08 needs a stopwatch -> measure the elapsed time from start to stop. In that case please take a look at QElapsedTimer classQElapsedTimer *timer = new ; connect(startButton, SIGNAL(clicked()), timer, SLOT(start())); connect(stoptButton, SIGNAL(clicked()), this, SLOT(reportElapsedTime())); void XX::reportElapsedTime() { qDebug() << "Elapsed time: " << timer.elapsed() << "milliseconds"; }
Spoiler alert: code not tested, just to show the idea
-
@Pablo-J.-Rogina said in Put Video Timer without using Design:
And I guess the idea is the opposite, the "timer" should start when the start button is pressed (the same button that starts video playing) and "timer" should stop when stop button is pressed.
That was actually my understanding.
-
@jsulm thanks so much Sir, I tried using this but it didn't work the way i intended it to.
Regards
-
@Pablo-J.-Rogina Thanks so much Sir, actually that is what I meant.
I am trying this method i.e. using the QElapsedTimer, I'll let you know if this works well.Regards