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

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

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

5条回答
  •  清歌不尽
    2021-01-04 11:29

    Qt provides an example in the 'context2d' project a way to access to the setInterval/clearInterval setTimeout/clearTimeout functionalities from the script.

    In the 'Environment' class of this project, the startTimer function of a QObject is called each time that the script invokes setInterval/setTimeout. Then the timer identifier is added in a QHash with a reference on the javascript callback. When the countdown of the timer (c++ part) is over, the timerEvent of the 'Environment' class is called and then the javascript callback called..

    Note that all the timers are killed in the Environment::reset() in order to clean the context.

    see: https://doc.qt.io/archives/qt-4.7/script-context2d.html

提交回复
热议问题