You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/ntqeventloop.html

281 lines
15 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qeventloop.cpp:41 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQEventLoop Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQEventLoop Class Reference</h1>
<p>The TQEventLoop class manages the event queue.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qeventloop-h.html">ntqeventloop.h</a>&gt;</tt>
<p>Inherits <a href="ntqobject.html">TQObject</a>.
<p>Inherited by <a href="qmotif.html">TQMotif</a>.
<p><a href="qeventloop-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQEventLoop"><b>TQEventLoop</b></a> ( TQObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~TQEventLoop"><b>~TQEventLoop</b></a> ()</li>
<li class=fn>enum <a href="#ProcessEvents-enum"><b>ProcessEvents</b></a> { AllEvents = 0x00, ExcludeUserInput = 0x01, ExcludeSocketNotifiers = 0x02, WaitForMore = 0x04 }</li>
<li class=fn>typedef uint&nbsp;<a href="#ProcessEventsFlags"><b>ProcessEventsFlags</b></a></li>
<li class=fn>void <a href="#processEvents"><b>processEvents</b></a> ( ProcessEventsFlags&nbsp;flags, int&nbsp;maxTime )</li>
<li class=fn>virtual bool <a href="#processEvents-2"><b>processEvents</b></a> ( ProcessEventsFlags&nbsp;flags )</li>
<li class=fn>virtual bool <a href="#hasPendingEvents"><b>hasPendingEvents</b></a> () const</li>
<li class=fn>virtual void <a href="#registerSocketNotifier"><b>registerSocketNotifier</b></a> ( TQSocketNotifier&nbsp;*&nbsp;notifier )</li>
<li class=fn>virtual void <a href="#unregisterSocketNotifier"><b>unregisterSocketNotifier</b></a> ( TQSocketNotifier&nbsp;*&nbsp;notifier )</li>
<li class=fn>void <a href="#setSocketNotifierPending"><b>setSocketNotifierPending</b></a> ( TQSocketNotifier&nbsp;*&nbsp;notifier )</li>
<li class=fn>int <a href="#activateSocketNotifiers"><b>activateSocketNotifiers</b></a> ()</li>
<li class=fn>int <a href="#activateTimers"><b>activateTimers</b></a> ()</li>
<li class=fn>int <a href="#timeToWait"><b>timeToWait</b></a> () const</li>
<li class=fn>virtual int <a href="#exec"><b>exec</b></a> ()</li>
<li class=fn>virtual void <a href="#exit"><b>exit</b></a> ( int&nbsp;retcode = 0 )</li>
<li class=fn>virtual int <a href="#enterLoop"><b>enterLoop</b></a> ()</li>
<li class=fn>virtual void <a href="#exitLoop"><b>exitLoop</b></a> ()</li>
<li class=fn>virtual int <a href="#loopLevel"><b>loopLevel</b></a> () const</li>
<li class=fn>virtual void <a href="#wakeUp"><b>wakeUp</b></a> ()</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#awake"><b>awake</b></a> ()</li>
<li class=fn>void <a href="#aboutToBlock"><b>aboutToBlock</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQEventLoop class manages the event queue.
<p>
<p> It receives events from the window system and other sources. It
then sends them to <a href="ntqapplication.html">TQApplication</a> for processing and delivery.
<p> TQEventLoop allows the application programmer to have more control
over event delivery. Programs that perform long operations can
call either processOneEvent() or <a href="#processEvents">processEvents</a>() with various
ProcessEvent values OR'ed together to control which events should
be delivered.
<p> TQEventLoop also allows the integration of an external event loop
with the TQt event loop. The <a href="motif-extension.html#Motif">Motif</a> Extension included with TQt
includes a reimplementation of TQEventLoop for merging TQt and Motif
events together.
<p> To use your own instance of TQEventLoop or TQEventLoop subclass create
it before you create the TQApplication object.
<p>See also <a href="application.html">Main Window and Related Classes</a> and <a href="events.html">Event Classes</a>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="ProcessEvents-enum"></a>TQEventLoop::ProcessEvents</h3>
<p> This enum controls the types of events processed by the
<a href="#processEvents">processEvents</a>() functions.
<ul>
<li><tt>TQEventLoop::AllEvents</tt> - All events are processed
<li><tt>TQEventLoop::ExcludeUserInput</tt> - Do not process user input events.
( ButtonPress, KeyPress, etc. )
<li><tt>TQEventLoop::ExcludeSocketNotifiers</tt> - Do not process socket notifier
events.
<li><tt>TQEventLoop::WaitForMore</tt> - Wait for events if no pending events
are available.
</ul><p> <p>See also <a href="#processEvents">processEvents</a>().
<h3 class=fn><a name="ProcessEventsFlags"></a>TQEventLoop::ProcessEventsFlags</h3>
A <tt>typedef</tt> to allow various ProcessEvents values to be OR'ed together.
<p> <p>See also <a href="#ProcessEvents-enum">ProcessEvents</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQEventLoop"></a>TQEventLoop::TQEventLoop ( <a href="ntqobject.html">TQObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Creates a TQEventLoop object, this object becomes the global event loop object.
There can only be one event loop object. The TQEventLoop is usually constructed
by calling <a href="ntqapplication.html#eventLoop">TQApplication::eventLoop</a>(). To create your own event loop object create
it before you instantiate the <a href="ntqapplication.html">TQApplication</a> object.
<p> The <em>parent</em> and <em>name</em> arguments are passed on to the <a href="ntqobject.html">TQObject</a> constructor.
<h3 class=fn><a name="~TQEventLoop"></a>TQEventLoop::~TQEventLoop ()
</h3>
Destructs the TQEventLoop object.
<h3 class=fn>void <a name="aboutToBlock"></a>TQEventLoop::aboutToBlock ()<tt> [signal]</tt>
</h3>
<p> This signal is emitted before the event loop calls a function that
could block.
<p> <p>See also <a href="#awake">awake</a>().
<h3 class=fn>int <a name="activateSocketNotifiers"></a>TQEventLoop::activateSocketNotifiers ()
</h3>
<p> Activates all pending socket notifiers and returns the number of
socket notifiers that were activated.
<h3 class=fn>int <a name="activateTimers"></a>TQEventLoop::activateTimers ()
</h3>
<p> Activates all TQt timers and returns the number of timers that were
activated.
<p> TQEventLoop subclasses that do their own timer handling need to
call this after the time returned by <a href="#timeToWait">timeToWait</a>() has elapsed.
<p> Note: This function is only useful on systems where <tt>select()</tt> is
used to block the eventloop. On Windows, this function always
returns 0. On MacOS X, this function always returns 0 when the
GUI is enabled. On MacOS X, this function returns the documented
value when the GUI is disabled.
<h3 class=fn>void <a name="awake"></a>TQEventLoop::awake ()<tt> [signal]</tt>
</h3>
<p> This signal is emitted after the event loop returns from a
function that could block.
<p> <p>See also <a href="#wakeUp">wakeUp</a>() and <a href="#aboutToBlock">aboutToBlock</a>().
<h3 class=fn>int <a name="enterLoop"></a>TQEventLoop::enterLoop ()<tt> [virtual]</tt>
</h3>
<p> This function enters the main event loop (recursively). Do not call
it unless you really know what you are doing.
<h3 class=fn>int <a name="exec"></a>TQEventLoop::exec ()<tt> [virtual]</tt>
</h3>
Enters the main event loop and waits until <a href="#exit">exit</a>() is called, and
returns the value that was set to exit().
<p> It is necessary to call this function to start event handling. The
main event loop receives events from the window system and
dispatches these to the application widgets.
<p> Generally speaking, no user interaction can take place before
calling <a href="#exec">exec</a>(). As a special case, modal widgets like <a href="ntqmessagebox.html">TQMessageBox</a>
can be used before calling exec(), because modal widgets call
exec() to start a local event loop.
<p> To make your application perform idle processing, i.e. executing a
special function whenever there are no pending events, use a
<a href="ntqtimer.html">TQTimer</a> with 0 timeout. More advanced idle processing schemes can
be achieved using <a href="#processEvents">processEvents</a>().
<p> <p>See also <a href="ntqapplication.html#quit">TQApplication::quit</a>(), <a href="#exit">exit</a>(), and <a href="#processEvents">processEvents</a>().
<h3 class=fn>void <a name="exit"></a>TQEventLoop::exit ( int&nbsp;retcode = 0 )<tt> [virtual]</tt>
</h3>
<p> Tells the event loop to exit with a return code.
<p> After this function has been called, the event loop returns from
the call to <a href="#exec">exec</a>(). The exec() function returns <em>retcode</em>.
<p> By convention, a <em>retcode</em> of 0 means success, and any non-zero
value indicates an error.
<p> Note that unlike the C library function of the same name, this
function <em>does</em> return to the caller -- it is event processing that
stops.
<p> <p>See also <a href="ntqapplication.html#quit">TQApplication::quit</a>() and <a href="#exec">exec</a>().
<h3 class=fn>void <a name="exitLoop"></a>TQEventLoop::exitLoop ()<tt> [virtual]</tt>
</h3>
<p> This function exits from a recursive call to the main event loop.
Do not call it unless you really know what you are doing.
<h3 class=fn>bool <a name="hasPendingEvents"></a>TQEventLoop::hasPendingEvents () const<tt> [virtual]</tt>
</h3>
<p> Returns TRUE if there is an event waiting, otherwise it returns FALSE.
<h3 class=fn>int <a name="loopLevel"></a>TQEventLoop::loopLevel () const<tt> [virtual]</tt>
</h3>
<p> Returns the current loop level.
<h3 class=fn>void <a name="processEvents"></a>TQEventLoop::processEvents ( <a href="ntqeventloop.html#ProcessEventsFlags">ProcessEventsFlags</a>&nbsp;flags, int&nbsp;maxTime )
</h3>
Process pending events that match <em>flags</em> for a maximum of <em>maxTime</em> milliseconds, or until there are no more events to
process, which ever is shorter.
<p> This function is especially useful if you have a long running
operation and want to show its progress without allowing user
input, i.e. by using the <a href="#ProcessEvents-enum">ExcludeUserInput</a> flag.
<p> NOTE: This function will not process events continuously; it
returns after all available events are processed.
<p> NOTE: Specifying the <a href="#ProcessEvents-enum">WaitForMore</a> flag makes no sense and will
be ignored.
<h3 class=fn>bool <a name="processEvents-2"></a>TQEventLoop::processEvents ( <a href="ntqeventloop.html#ProcessEventsFlags">ProcessEventsFlags</a>&nbsp;flags )<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Processes pending events that match <em>flags</em> until there are no
more events to process.
<p> This function is especially useful if you have a long running
operation and want to show its progress without allowing user
input, i.e. by using the <a href="#ProcessEvents-enum">ExcludeUserInput</a> flag.
<p> If the <a href="#ProcessEvents-enum">WaitForMore</a> flag is set in <em>flags</em>, the behavior of
this function is as follows:
<p> <ul>
<p> <li> If events are available, this function returns after processing
them.
<p> <li> If no events are available, this function will wait until more
are available and return after processing newly available events.
<p> </ul>
<p> If the <a href="#ProcessEvents-enum">WaitForMore</a> flag is <em>not</em> set in <em>flags</em>, and no
events are available, this function will return immediately.
<p> NOTE: This function will not process events continuously; it
returns after all available events are processed.
<p> This function returns TRUE if an event was processed; otherwise it
returns FALSE.
<p> <p>See also <a href="#ProcessEvents-enum">ProcessEvents</a> and <a href="#hasPendingEvents">hasPendingEvents</a>().
<h3 class=fn>void <a name="registerSocketNotifier"></a>TQEventLoop::registerSocketNotifier ( <a href="ntqsocketnotifier.html">TQSocketNotifier</a>&nbsp;*&nbsp;notifier )<tt> [virtual]</tt>
</h3>
<p> Registers <em>notifier</em> with the event loop. Subclasses need to
reimplement this method to tie a socket notifier into another
event loop. Reimplementations <em>MUST</em> call the base
implementation.
<h3 class=fn>void <a name="setSocketNotifierPending"></a>TQEventLoop::setSocketNotifierPending ( <a href="ntqsocketnotifier.html">TQSocketNotifier</a>&nbsp;*&nbsp;notifier )
</h3>
<p> Marks <em>notifier</em> as pending. The socket notifier will be
activated the next time <a href="#activateSocketNotifiers">activateSocketNotifiers</a>() is called.
<h3 class=fn>int <a name="timeToWait"></a>TQEventLoop::timeToWait () const
</h3>
<p> Returns the number of milliseconds that TQt needs to handle its
timers or -1 if there are no timers running.
<p> TQEventLoop subclasses that do their own timer handling need to use
this to make sure that TQt's timers continue to work.
<p> Note: This function is only useful on systems where <tt>select()</tt> is
used to block the eventloop. On Windows, this function always
returns -1. On MacOS X, this function always returns -1 when the
GUI is enabled. On MacOS X, this function returns the documented
value when the GUI is disabled.
<h3 class=fn>void <a name="unregisterSocketNotifier"></a>TQEventLoop::unregisterSocketNotifier ( <a href="ntqsocketnotifier.html">TQSocketNotifier</a>&nbsp;*&nbsp;notifier )<tt> [virtual]</tt>
</h3>
<p> Unregisters <em>notifier</em> from the event loop. Subclasses need to
reimplement this method to tie a socket notifier into another
event loop. Reimplementations <em>MUST</em> call the base
implementation.
<h3 class=fn>void <a name="wakeUp"></a>TQEventLoop::wakeUp ()<tt> [virtual]</tt>
</h3><p><b>Note:</b> This function is <a href="threads.html#threadsafe">thread-safe</a> when TQt is built withthread support.</p>
<p> Wakes up the event loop.
<p> <p>See also <a href="#awake">awake</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>