lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9 May 2012 13:22, Rob Hoelz <rob@hoelz.ro> wrote:
> So let's say I wanted to print 'hello' a second after a user
> clicked a button in a GUI.  I could do something like this:
>
>  -- this assumes that the GUI plays nicely with the event loop
>  button:onclick(function()
>    ev:sleep(1)
>    print 'hi'
>  end)
>
> and other events would continue to fire while the button handler is
> sleeping.

This should be doable with Qt. The proposed library should provide a
generic way for other libraries to "register themselves" onto the
event loop using a "step" function to query/handle a single/few
events.

In Qt you would implement this step function using
QCoreLibrary::processEvents(QEventLoop::AllEvents) to handle GUI
events and give back control to the event library, so that it could
process other stuff, such as networking. You can even specify a
timeout which you are willing to wait, like "spend max 100ms
processing Qt events" -
QCoreLibrary::processEvents(QEventLoop::AllEvents, 100).