Not much to add; what is the equivalent of JavaScript\'s setTimeout on qtScript?
Here's my submission for "kludge of the year"... but this works AND doesn't require recompiling the C++ back end, in a context where that is way too much work to get involved with! I'm not sure how the rest of you may be using the now defunk Qt Script, but my need is for the Qt Installer Framework, and I want to just use it out of the box - not via a custom fork of the whole tool set, for me to then try to maintain (since QtIFW itself is still actively updated), or have to port around, compile on alternate platforms, share with collaborators...
So what's my solution? Well there's no QTimer
exposed the to standard script engine, but you can define your own custom (i.e. "dynamic") installer wizard pages, defining the interface via Qt forms (.ui files). With that, you can drop in any QWidget, and then add connections for the signals and slots on the Qt Script side... And so, I just used the first, and perhaps most simplistic, set of widget signals and slots which I saw had some sort of timer mechanism built in that I might capitalize upon.
In a custom form, drop this in somewhere, adding a hidden QPushButton:
false
Then, when you load the component containing the .ui (form), connect the button's "released" signal to a custom "slot" (i.e. Qt Script function):
Component.prototype.componentLoaded = function(){
var page = gui.pageWidgetByObjectName("DynamicMyTimerKludgePage");
page.timerKludgeButton.released.connect(this, this.onTimeOut);
}
Next, define the slot:
Component.prototype.onTimeOut = function(){
console.log("Asynchronous time out!");
}
Finally, where applicable, start your "timer" with the core trick here, using the QPushButton's "animateClick" function:
var page = gui.pageWidgetByObjectName("DynamicMyTimerKludgePage");
page.timerKludgeButton.animateClick(2000);