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.
qt3/doc/html/qeventloop.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>QEventLoop 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>QEventLoop Class Reference</h1>
<p>The QEventLoop class manages the event queue.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qeventloop-h.html">qeventloop.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p>Inherited by <a href="qmotif.html">QMotif</a>.
<p><a href="qeventloop-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QEventLoop"><b>QEventLoop</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#~QEventLoop"><b>~QEventLoop</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> ( QSocketNotifier&nbsp;*&nbsp;notifier )</li>
<li class=fn>virtual void <a href="#unregisterSocketNotifier"><b>unregisterSocketNotifier</b></a> ( QSocketNotifier&nbsp;*&nbsp;notifier )</li>
<li class=fn>void <a href="#setSocketNotifierPending"><b>setSocketNotifierPending</b></a> ( QSocketNotifier&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 QEventLoop class manages the event queue.
<p>
<p> It receives events from the window system and other sources. It
then sends them to <a href="qapplication.html">QApplication</a> for processing and delivery.
<p> QEventLoop 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> QEventLoop also allows the integration of an external event loop
with the Qt event loop. The <a href="motif-extension.html#Motif">Motif</a> Extension included with Qt
includes a reimplementation of QEventLoop for merging Qt and Motif
events together.
<p> To use your own instance of QEventLoop or QEventLoop subclass create
it before you create the QApplication 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>QEventLoop::ProcessEvents</h3>
<p> This enum controls the types of events processed by the
<a href="#processEvents">processEvents</a>() functions.
<ul>
<li><tt>QEventLoop::AllEvents</tt> - All events are processed
<li><tt>QEventLoop::ExcludeUserInput</tt> - Do not process user input events.
( ButtonPress, KeyPress, etc. )
<li><tt>QEventLoop::ExcludeSocketNotifiers</tt> - Do not process socket notifier
events.
<li><tt>QEventLoop::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>QEventLoop::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="QEventLoop"></a>QEventLoop::QEventLoop ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Creates a QEventLoop object, this object becomes the global event loop object.
There can only be one event loop object. The QEventLoop is usually constructed
by calling <a href="qapplication.html#eventLoop">QApplication::eventLoop</a>(). To create your own event loop object create
it before you instantiate the <a href="qapplication.html">QApplication</a> object.
<p> The <em>parent</em> and <em>name</em> arguments are passed on to the <a href="qobject.html">QObject</a> constructor.
<h3 class=fn><a name="~QEventLoop"></a>QEventLoop::~QEventLoop ()
</h3>
Destructs the QEventLoop object.
<h3 class=fn>void <a name="aboutToBlock"></a>QEventLoop::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>QEventLoop::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>QEventLoop::activateTimers ()
</h3>
<p> Activates all Qt timers and returns the number of timers that were
activated.
<p> QEventLoop 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>QEventLoop::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>QEventLoop::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>QEventLoop::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="qmessagebox.html">QMessageBox</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="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can
be achieved using <a href="#processEvents">processEvents</a>().
<p> <p>See also <a href="qapplication.html#quit">QApplication::quit</a>(), <a href="#exit">exit</a>(), and <a href="#processEvents">processEvents</a>().
<h3 class=fn>void <a name="exit"></a>QEventLoop::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="qapplication.html#quit">QApplication::quit</a>() and <a href="#exec">exec</a>().
<h3 class=fn>void <a name="exitLoop"></a>QEventLoop::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>QEventLoop::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>QEventLoop::loopLevel () const<tt> [virtual]</tt>
</h3>
<p> Returns the current loop level.
<h3 class=fn>void <a name="processEvents"></a>QEventLoop::processEvents ( <a href="qeventloop.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>QEventLoop::processEvents ( <a href="qeventloop.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>QEventLoop::registerSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</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>QEventLoop::setSocketNotifierPending ( <a href="qsocketnotifier.html">QSocketNotifier</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>QEventLoop::timeToWait () const
</h3>
<p> Returns the number of milliseconds that Qt needs to handle its
timers or -1 if there are no timers running.
<p> QEventLoop subclasses that do their own timer handling need to use
this to make sure that Qt'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>QEventLoop::unregisterSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</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>QEventLoop::wakeUp ()<tt> [virtual]</tt>
</h3><p><b>Note:</b> This function is <a href="threads.html#threadsafe">thread-safe</a> when Qt 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">Qt 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>Qt 3.3.8</div>
</table></div></address></body>
</html>