Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › I need help building a countdown timer /Geri sayım sayacı yapmaya çalışıyorum.

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #18839

    Yusuf Umut Piynar

    I am trying to create a countdown timer but I dont know how to make that.

    My code is something like that :

    Component.onCompleted: {

                countdown("2018-12-31")
            }
            function countdown(startTime) {
                var start = new Date(startTime);
                var now = new Date();
                var timeDiff = start.getTime() - now.getTime();
                if (timeDiff <= 0) {
                    clearTimeout(timer);
                    document.write('Performance Started')
                }
                var seconds = Math.floor(timeDiff / 1000);
                var minutes = Math.floor(seconds / 60);
                var hours = Math.floor(minutes / 60);
                var days = Math.floor(hours / 24);
    
    
                hours %= 24;
                minutes %= 60;
                seconds %= 60;
    
    
                var output = days + " days" + "," + hours + " hours, " + minutes + " minutes, " + seconds + " seconds."
                timerSecs.text =seconds
                return output;
                var timer = setTimeout('cdtd()', 1000)
            }
    
    But I dont know how an i make this timer repeats and works without stopping.
    
    Niyazi sen Türksün, Türkçe daha iyi anlaşırız yardım edersen sevinirim.
    #18840

    Marcin

    Hi,
    You don’t need to use JS to create timers in QT and QML.
    QML already has a Timer component https://doc.qt.io/qt-5/qml-qtqml-timer.html

    repeat: true,  interval: 3000(for 3 seconds) and put your logic(JS) to onTriggered function.

    #18890

    Niyazi

    Well, @Marcin said perfectly. Qt & QML has Timer component. Specially look at this.

    http://doc.qt.io/qt-5.6/qtquick-demos-maroon-example.html Search Using Timer Section.

    It is good to use English in Felgo Forums. So everyone can contribute and share the knowledge.
    <h2 id=”using-timers”></h2>

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.