source: trunk/doc/html/qeventloop.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.0 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qeventloop.cpp:41 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QEventLoop Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QEventLoop class manages the event queue.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qeventloop-h.html">qeventloop.h</a>&gt;</tt>
37<p>Inherits <a href="qobject.html">QObject</a>.
38<p>Inherited by <a href="qmotif.html">QMotif</a>.
39<p><a href="qeventloop-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QEventLoop"><b>QEventLoop</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn><a href="#~QEventLoop"><b>~QEventLoop</b></a> ()</li>
44<li class=fn>enum <a href="#ProcessEvents-enum"><b>ProcessEvents</b></a> { AllEvents = 0x00, ExcludeUserInput = 0x01, ExcludeSocketNotifiers = 0x02, WaitForMore = 0x04 }</li>
45<li class=fn>typedef uint&nbsp;<a href="#ProcessEventsFlags"><b>ProcessEventsFlags</b></a></li>
46<li class=fn>void <a href="#processEvents"><b>processEvents</b></a> ( ProcessEventsFlags&nbsp;flags, int&nbsp;maxTime )</li>
47<li class=fn>virtual bool <a href="#processEvents-2"><b>processEvents</b></a> ( ProcessEventsFlags&nbsp;flags )</li>
48<li class=fn>virtual bool <a href="#hasPendingEvents"><b>hasPendingEvents</b></a> () const</li>
49<li class=fn>virtual void <a href="#registerSocketNotifier"><b>registerSocketNotifier</b></a> ( QSocketNotifier&nbsp;*&nbsp;notifier )</li>
50<li class=fn>virtual void <a href="#unregisterSocketNotifier"><b>unregisterSocketNotifier</b></a> ( QSocketNotifier&nbsp;*&nbsp;notifier )</li>
51<li class=fn>void <a href="#setSocketNotifierPending"><b>setSocketNotifierPending</b></a> ( QSocketNotifier&nbsp;*&nbsp;notifier )</li>
52<li class=fn>int <a href="#activateSocketNotifiers"><b>activateSocketNotifiers</b></a> ()</li>
53<li class=fn>int <a href="#activateTimers"><b>activateTimers</b></a> ()</li>
54<li class=fn>int <a href="#timeToWait"><b>timeToWait</b></a> () const</li>
55<li class=fn>virtual int <a href="#exec"><b>exec</b></a> ()</li>
56<li class=fn>virtual void <a href="#exit"><b>exit</b></a> ( int&nbsp;retcode = 0 )</li>
57<li class=fn>virtual int <a href="#enterLoop"><b>enterLoop</b></a> ()</li>
58<li class=fn>virtual void <a href="#exitLoop"><b>exitLoop</b></a> ()</li>
59<li class=fn>virtual int <a href="#loopLevel"><b>loopLevel</b></a> () const</li>
60<li class=fn>virtual void <a href="#wakeUp"><b>wakeUp</b></a> ()</li>
61</ul>
62<h2>Signals</h2>
63<ul>
64<li class=fn>void <a href="#awake"><b>awake</b></a> ()</li>
65<li class=fn>void <a href="#aboutToBlock"><b>aboutToBlock</b></a> ()</li>
66</ul>
67<hr><a name="details"></a><h2>Detailed Description</h2>
68
69
70The QEventLoop class manages the event queue.
71<p>
72
73<p> It receives events from the window system and other sources. It
74then sends them to <a href="qapplication.html">QApplication</a> for processing and delivery.
75<p> QEventLoop allows the application programmer to have more control
76over event delivery. Programs that perform long operations can
77call either processOneEvent() or <a href="#processEvents">processEvents</a>() with various
78ProcessEvent values OR'ed together to control which events should
79be delivered.
80<p> QEventLoop also allows the integration of an external event loop
81with the Qt event loop. The <a href="motif-extension.html#Motif">Motif</a> Extension included with Qt
82includes a reimplementation of QEventLoop for merging Qt and Motif
83events together.
84<p> To use your own instance of QEventLoop or QEventLoop subclass create
85it before you create the QApplication object.
86<p>See also <a href="application.html">Main Window and Related Classes</a> and <a href="events.html">Event Classes</a>.
87
88<hr><h2>Member Type Documentation</h2>
89<h3 class=fn><a name="ProcessEvents-enum"></a>QEventLoop::ProcessEvents</h3>
90<p> This enum controls the types of events processed by the
91<a href="#processEvents">processEvents</a>() functions.
92<ul>
93<li><tt>QEventLoop::AllEvents</tt> - All events are processed
94<li><tt>QEventLoop::ExcludeUserInput</tt> - Do not process user input events.
95( ButtonPress, KeyPress, etc. )
96<li><tt>QEventLoop::ExcludeSocketNotifiers</tt> - Do not process socket notifier
97events.
98<li><tt>QEventLoop::WaitForMore</tt> - Wait for events if no pending events
99are available.
100</ul><p> <p>See also <a href="#processEvents">processEvents</a>().
101
102<h3 class=fn><a name="ProcessEventsFlags"></a>QEventLoop::ProcessEventsFlags</h3>
103A <tt>typedef</tt> to allow various ProcessEvents values to be OR'ed together.
104<p> <p>See also <a href="#ProcessEvents-enum">ProcessEvents</a>.
105
106<hr><h2>Member Function Documentation</h2>
107<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 )
108</h3>
109Creates a QEventLoop object, this object becomes the global event loop object.
110There can only be one event loop object. The QEventLoop is usually constructed
111by calling <a href="qapplication.html#eventLoop">QApplication::eventLoop</a>(). To create your own event loop object create
112it before you instantiate the <a href="qapplication.html">QApplication</a> object.
113<p> The <em>parent</em> and <em>name</em> arguments are passed on to the <a href="qobject.html">QObject</a> constructor.
114
115<h3 class=fn><a name="~QEventLoop"></a>QEventLoop::~QEventLoop ()
116</h3>
117Destructs the QEventLoop object.
118
119<h3 class=fn>void <a name="aboutToBlock"></a>QEventLoop::aboutToBlock ()<tt> [signal]</tt>
120</h3>
121<p> This signal is emitted before the event loop calls a function that
122could block.
123<p> <p>See also <a href="#awake">awake</a>().
124
125<h3 class=fn>int <a name="activateSocketNotifiers"></a>QEventLoop::activateSocketNotifiers ()
126</h3>
127<p> Activates all pending socket notifiers and returns the number of
128socket notifiers that were activated.
129
130<h3 class=fn>int <a name="activateTimers"></a>QEventLoop::activateTimers ()
131</h3>
132<p> Activates all Qt timers and returns the number of timers that were
133activated.
134<p> QEventLoop subclasses that do their own timer handling need to
135call this after the time returned by <a href="#timeToWait">timeToWait</a>() has elapsed.
136<p> Note: This function is only useful on systems where <tt>select()</tt> is
137used to block the eventloop. On Windows, this function always
138returns 0. On MacOS X, this function always returns 0 when the
139GUI is enabled. On MacOS X, this function returns the documented
140value when the GUI is disabled.
141
142<h3 class=fn>void <a name="awake"></a>QEventLoop::awake ()<tt> [signal]</tt>
143</h3>
144<p> This signal is emitted after the event loop returns from a
145function that could block.
146<p> <p>See also <a href="#wakeUp">wakeUp</a>() and <a href="#aboutToBlock">aboutToBlock</a>().
147
148<h3 class=fn>int <a name="enterLoop"></a>QEventLoop::enterLoop ()<tt> [virtual]</tt>
149</h3>
150<p> This function enters the main event loop (recursively). Do not call
151it unless you really know what you are doing.
152
153<h3 class=fn>int <a name="exec"></a>QEventLoop::exec ()<tt> [virtual]</tt>
154</h3>
155Enters the main event loop and waits until <a href="#exit">exit</a>() is called, and
156returns the value that was set to exit().
157<p> It is necessary to call this function to start event handling. The
158main event loop receives events from the window system and
159dispatches these to the application widgets.
160<p> Generally speaking, no user interaction can take place before
161calling <a href="#exec">exec</a>(). As a special case, modal widgets like <a href="qmessagebox.html">QMessageBox</a>
162can be used before calling exec(), because modal widgets call
163exec() to start a local event loop.
164<p> To make your application perform idle processing, i.e. executing a
165special function whenever there are no pending events, use a
166<a href="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can
167be achieved using <a href="#processEvents">processEvents</a>().
168<p> <p>See also <a href="qapplication.html#quit">QApplication::quit</a>(), <a href="#exit">exit</a>(), and <a href="#processEvents">processEvents</a>().
169
170<h3 class=fn>void <a name="exit"></a>QEventLoop::exit ( int&nbsp;retcode = 0 )<tt> [virtual]</tt>
171</h3>
172<p> Tells the event loop to exit with a return code.
173<p> After this function has been called, the event loop returns from
174the call to <a href="#exec">exec</a>(). The exec() function returns <em>retcode</em>.
175<p> By convention, a <em>retcode</em> of 0 means success, and any non-zero
176value indicates an error.
177<p> Note that unlike the C library function of the same name, this
178function <em>does</em> return to the caller -- it is event processing that
179stops.
180<p> <p>See also <a href="qapplication.html#quit">QApplication::quit</a>() and <a href="#exec">exec</a>().
181
182<h3 class=fn>void <a name="exitLoop"></a>QEventLoop::exitLoop ()<tt> [virtual]</tt>
183</h3>
184<p> This function exits from a recursive call to the main event loop.
185Do not call it unless you really know what you are doing.
186
187<h3 class=fn>bool <a name="hasPendingEvents"></a>QEventLoop::hasPendingEvents () const<tt> [virtual]</tt>
188</h3>
189<p> Returns TRUE if there is an event waiting, otherwise it returns FALSE.
190
191<h3 class=fn>int <a name="loopLevel"></a>QEventLoop::loopLevel () const<tt> [virtual]</tt>
192</h3>
193<p> Returns the current loop level.
194
195<h3 class=fn>void <a name="processEvents"></a>QEventLoop::processEvents ( <a href="qeventloop.html#ProcessEventsFlags">ProcessEventsFlags</a>&nbsp;flags, int&nbsp;maxTime )
196</h3>
197Process pending events that match <em>flags</em> for a maximum of <em>maxTime</em> milliseconds, or until there are no more events to
198process, which ever is shorter.
199<p> This function is especially useful if you have a long running
200operation and want to show its progress without allowing user
201input, i.e. by using the <a href="#ProcessEvents-enum">ExcludeUserInput</a> flag.
202<p> NOTE: This function will not process events continuously; it
203returns after all available events are processed.
204<p> NOTE: Specifying the <a href="#ProcessEvents-enum">WaitForMore</a> flag makes no sense and will
205be ignored.
206
207<h3 class=fn>bool <a name="processEvents-2"></a>QEventLoop::processEvents ( <a href="qeventloop.html#ProcessEventsFlags">ProcessEventsFlags</a>&nbsp;flags )<tt> [virtual]</tt>
208</h3>
209
210This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
211<p> Processes pending events that match <em>flags</em> until there are no
212more events to process.
213<p> This function is especially useful if you have a long running
214operation and want to show its progress without allowing user
215input, i.e. by using the <a href="#ProcessEvents-enum">ExcludeUserInput</a> flag.
216<p> If the <a href="#ProcessEvents-enum">WaitForMore</a> flag is set in <em>flags</em>, the behavior of
217this function is as follows:
218<p> <ul>
219<p> <li> If events are available, this function returns after processing
220them.
221<p> <li> If no events are available, this function will wait until more
222are available and return after processing newly available events.
223<p> </ul>
224<p> If the <a href="#ProcessEvents-enum">WaitForMore</a> flag is <em>not</em> set in <em>flags</em>, and no
225events are available, this function will return immediately.
226<p> NOTE: This function will not process events continuously; it
227returns after all available events are processed.
228<p> This function returns TRUE if an event was processed; otherwise it
229returns FALSE.
230<p> <p>See also <a href="#ProcessEvents-enum">ProcessEvents</a> and <a href="#hasPendingEvents">hasPendingEvents</a>().
231
232<h3 class=fn>void <a name="registerSocketNotifier"></a>QEventLoop::registerSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</a>&nbsp;*&nbsp;notifier )<tt> [virtual]</tt>
233</h3>
234<p> Registers <em>notifier</em> with the event loop. Subclasses need to
235reimplement this method to tie a socket notifier into another
236event loop. Reimplementations <em>MUST</em> call the base
237implementation.
238
239<h3 class=fn>void <a name="setSocketNotifierPending"></a>QEventLoop::setSocketNotifierPending ( <a href="qsocketnotifier.html">QSocketNotifier</a>&nbsp;*&nbsp;notifier )
240</h3>
241<p> Marks <em>notifier</em> as pending. The socket notifier will be
242activated the next time <a href="#activateSocketNotifiers">activateSocketNotifiers</a>() is called.
243
244<h3 class=fn>int <a name="timeToWait"></a>QEventLoop::timeToWait () const
245</h3>
246<p> Returns the number of milliseconds that Qt needs to handle its
247timers or -1 if there are no timers running.
248<p> QEventLoop subclasses that do their own timer handling need to use
249this to make sure that Qt's timers continue to work.
250<p> Note: This function is only useful on systems where <tt>select()</tt> is
251used to block the eventloop. On Windows, this function always
252returns -1. On MacOS X, this function always returns -1 when the
253GUI is enabled. On MacOS X, this function returns the documented
254value when the GUI is disabled.
255
256<h3 class=fn>void <a name="unregisterSocketNotifier"></a>QEventLoop::unregisterSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</a>&nbsp;*&nbsp;notifier )<tt> [virtual]</tt>
257</h3>
258<p> Unregisters <em>notifier</em> from the event loop. Subclasses need to
259reimplement this method to tie a socket notifier into another
260event loop. Reimplementations <em>MUST</em> call the base
261implementation.
262
263<h3 class=fn>void <a name="wakeUp"></a>QEventLoop::wakeUp ()<tt> [virtual]</tt>
264</h3><p><b>Note:</b> This function is <a href="threads.html#threadsafe">thread-safe</a> when Qt is built withthread support.</p>
265
266
267<p> Wakes up the event loop.
268<p> <p>See also <a href="#awake">awake</a>().
269
270<!-- eof -->
271<hr><p>
272This file is part of the <a href="index.html">Qt toolkit</a>.
273Copyright &copy; 1995-2007
274<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
275<table width=100% cellspacing=0 border=0><tr>
276<td>Copyright &copy; 2007
277<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
278<td align=right><div align=right>Qt 3.3.8</div>
279</table></div></address></body>
280</html>
Note: See TracBrowser for help on using the repository browser.