Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 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.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded