[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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 <<a href="qeventloop-h.html">qeventloop.h</a>></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 * parent = 0, const char * 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 <a href="#ProcessEventsFlags"><b>ProcessEventsFlags</b></a></li>
|
---|
| 46 | <li class=fn>void <a href="#processEvents"><b>processEvents</b></a> ( ProcessEventsFlags flags, int maxTime )</li>
|
---|
| 47 | <li class=fn>virtual bool <a href="#processEvents-2"><b>processEvents</b></a> ( ProcessEventsFlags 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 * notifier )</li>
|
---|
| 50 | <li class=fn>virtual void <a href="#unregisterSocketNotifier"><b>unregisterSocketNotifier</b></a> ( QSocketNotifier * notifier )</li>
|
---|
| 51 | <li class=fn>void <a href="#setSocketNotifierPending"><b>setSocketNotifierPending</b></a> ( QSocketNotifier * 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 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 |
|
---|
| 70 | The QEventLoop class manages the event queue.
|
---|
| 71 | <p>
|
---|
| 72 |
|
---|
| 73 | <p> It receives events from the window system and other sources. It
|
---|
| 74 | then sends them to <a href="qapplication.html">QApplication</a> for processing and delivery.
|
---|
| 75 | <p> QEventLoop allows the application programmer to have more control
|
---|
| 76 | over event delivery. Programs that perform long operations can
|
---|
| 77 | call either processOneEvent() or <a href="#processEvents">processEvents</a>() with various
|
---|
| 78 | ProcessEvent values OR'ed together to control which events should
|
---|
| 79 | be delivered.
|
---|
| 80 | <p> QEventLoop also allows the integration of an external event loop
|
---|
| 81 | with the Qt event loop. The <a href="motif-extension.html#Motif">Motif</a> Extension included with Qt
|
---|
| 82 | includes a reimplementation of QEventLoop for merging Qt and Motif
|
---|
| 83 | events together.
|
---|
| 84 | <p> To use your own instance of QEventLoop or QEventLoop subclass create
|
---|
| 85 | it 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
|
---|
| 97 | events.
|
---|
| 98 | <li><tt>QEventLoop::WaitForMore</tt> - Wait for events if no pending events
|
---|
| 99 | are available.
|
---|
| 100 | </ul><p> <p>See also <a href="#processEvents">processEvents</a>().
|
---|
| 101 |
|
---|
| 102 | <h3 class=fn><a name="ProcessEventsFlags"></a>QEventLoop::ProcessEventsFlags</h3>
|
---|
| 103 | A <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> * parent = 0, const char * name = 0 )
|
---|
| 108 | </h3>
|
---|
| 109 | Creates a QEventLoop object, this object becomes the global event loop object.
|
---|
| 110 | There can only be one event loop object. The QEventLoop is usually constructed
|
---|
| 111 | by calling <a href="qapplication.html#eventLoop">QApplication::eventLoop</a>(). To create your own event loop object create
|
---|
| 112 | it 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>
|
---|
| 117 | Destructs 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
|
---|
| 122 | could 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
|
---|
| 128 | socket 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
|
---|
| 133 | activated.
|
---|
| 134 | <p> QEventLoop subclasses that do their own timer handling need to
|
---|
| 135 | call 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
|
---|
| 137 | used to block the eventloop. On Windows, this function always
|
---|
| 138 | returns 0. On MacOS X, this function always returns 0 when the
|
---|
| 139 | GUI is enabled. On MacOS X, this function returns the documented
|
---|
| 140 | value 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
|
---|
| 145 | function 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
|
---|
| 151 | it 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>
|
---|
| 155 | Enters the main event loop and waits until <a href="#exit">exit</a>() is called, and
|
---|
| 156 | returns the value that was set to exit().
|
---|
| 157 | <p> It is necessary to call this function to start event handling. The
|
---|
| 158 | main event loop receives events from the window system and
|
---|
| 159 | dispatches these to the application widgets.
|
---|
| 160 | <p> Generally speaking, no user interaction can take place before
|
---|
| 161 | calling <a href="#exec">exec</a>(). As a special case, modal widgets like <a href="qmessagebox.html">QMessageBox</a>
|
---|
| 162 | can be used before calling exec(), because modal widgets call
|
---|
| 163 | exec() to start a local event loop.
|
---|
| 164 | <p> To make your application perform idle processing, i.e. executing a
|
---|
| 165 | special 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
|
---|
| 167 | be 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 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
|
---|
| 174 | the 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
|
---|
| 176 | value indicates an error.
|
---|
| 177 | <p> Note that unlike the C library function of the same name, this
|
---|
| 178 | function <em>does</em> return to the caller -- it is event processing that
|
---|
| 179 | stops.
|
---|
| 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.
|
---|
| 185 | Do 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> flags, int maxTime )
|
---|
| 196 | </h3>
|
---|
| 197 | Process pending events that match <em>flags</em> for a maximum of <em>maxTime</em> milliseconds, or until there are no more events to
|
---|
| 198 | process, which ever is shorter.
|
---|
| 199 | <p> This function is especially useful if you have a long running
|
---|
| 200 | operation and want to show its progress without allowing user
|
---|
| 201 | input, i.e. by using the <a href="#ProcessEvents-enum">ExcludeUserInput</a> flag.
|
---|
| 202 | <p> NOTE: This function will not process events continuously; it
|
---|
| 203 | returns after all available events are processed.
|
---|
| 204 | <p> NOTE: Specifying the <a href="#ProcessEvents-enum">WaitForMore</a> flag makes no sense and will
|
---|
| 205 | be ignored.
|
---|
| 206 |
|
---|
| 207 | <h3 class=fn>bool <a name="processEvents-2"></a>QEventLoop::processEvents ( <a href="qeventloop.html#ProcessEventsFlags">ProcessEventsFlags</a> flags )<tt> [virtual]</tt>
|
---|
| 208 | </h3>
|
---|
| 209 |
|
---|
| 210 | This 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
|
---|
| 212 | more events to process.
|
---|
| 213 | <p> This function is especially useful if you have a long running
|
---|
| 214 | operation and want to show its progress without allowing user
|
---|
| 215 | input, 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
|
---|
| 217 | this function is as follows:
|
---|
| 218 | <p> <ul>
|
---|
| 219 | <p> <li> If events are available, this function returns after processing
|
---|
| 220 | them.
|
---|
| 221 | <p> <li> If no events are available, this function will wait until more
|
---|
| 222 | are 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
|
---|
| 225 | events are available, this function will return immediately.
|
---|
| 226 | <p> NOTE: This function will not process events continuously; it
|
---|
| 227 | returns after all available events are processed.
|
---|
| 228 | <p> This function returns TRUE if an event was processed; otherwise it
|
---|
| 229 | returns 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> * notifier )<tt> [virtual]</tt>
|
---|
| 233 | </h3>
|
---|
| 234 | <p> Registers <em>notifier</em> with the event loop. Subclasses need to
|
---|
| 235 | reimplement this method to tie a socket notifier into another
|
---|
| 236 | event loop. Reimplementations <em>MUST</em> call the base
|
---|
| 237 | implementation.
|
---|
| 238 |
|
---|
| 239 | <h3 class=fn>void <a name="setSocketNotifierPending"></a>QEventLoop::setSocketNotifierPending ( <a href="qsocketnotifier.html">QSocketNotifier</a> * notifier )
|
---|
| 240 | </h3>
|
---|
| 241 | <p> Marks <em>notifier</em> as pending. The socket notifier will be
|
---|
| 242 | activated 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
|
---|
| 247 | timers or -1 if there are no timers running.
|
---|
| 248 | <p> QEventLoop subclasses that do their own timer handling need to use
|
---|
| 249 | this 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
|
---|
| 251 | used to block the eventloop. On Windows, this function always
|
---|
| 252 | returns -1. On MacOS X, this function always returns -1 when the
|
---|
| 253 | GUI is enabled. On MacOS X, this function returns the documented
|
---|
| 254 | value when the GUI is disabled.
|
---|
| 255 |
|
---|
| 256 | <h3 class=fn>void <a name="unregisterSocketNotifier"></a>QEventLoop::unregisterSocketNotifier ( <a href="qsocketnotifier.html">QSocketNotifier</a> * notifier )<tt> [virtual]</tt>
|
---|
| 257 | </h3>
|
---|
| 258 | <p> Unregisters <em>notifier</em> from the event loop. Subclasses need to
|
---|
| 259 | reimplement this method to tie a socket notifier into another
|
---|
| 260 | event loop. Reimplementations <em>MUST</em> call the base
|
---|
| 261 | implementation.
|
---|
| 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>
|
---|
| 272 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 273 | Copyright © 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 © 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>
|
---|