What is the equivalent of JavaScript's setTimeout on qtScript?

后端 未结 5 1290
清酒与你
清酒与你 2021-01-04 11:18

Not much to add; what is the equivalent of JavaScript\'s setTimeout on qtScript?

5条回答
  •  天命终不由人
    2021-01-04 11:48

    setTimeout and setInterval are not defined in ECMAScript specification because they are not JavaScript features. These functions are part of browser environments. So, QTscript does not have them.

    You can use QTimer to achive this functionality. Here is a quick code how to use it in QTScript.

    var timer = new QTimer();
    timer.interval = 100; // set the time in milliseconds
    timer.singleShot = true; // in-case if setTimout and false in-case of setInterval 
    timer.timeout.connect(this, function(){console("in setTimout")});
    timer.start();
    

    Watch out for any bugs, I just coded it here.

提交回复
热议问题