Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > d2229253b8f3127ab89b179a82cc8466 > files > 584

libqxt-devel-0.6.1-2.fc15.i686.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /builddir/build/BUILD/libqxt/src/core/qxtsignalwaiter.cpp -->
<head>
  <title>QxtSignalWaiter Class Reference</title>
  <link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://libqxt.org"><img src="images/qxt-logo.png" width="50" height="40" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">Classes</font></a>&nbsp;&middot; <a href="namespaces.html"><font color="#004faf">Namespaces</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QxtSignalWaiter Class Reference<br /><span class="small-subtitle">[<a href="qxtcore.html">QxtCore</a> module]</span>
</h1>
<p>The QxtSignalWaiter class blocks and processes events until a signal is emitted <a href="#details">More...</a></p>
<pre>    #include &lt;QxtSignalWaiter&gt;</pre><p>Inherits <a href="http://doc.qtsoftware.com/4.5/qobject.html">QObject</a>.</p>
<ul>
<li><a href="qxtsignalwaiter-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"></div><b><a href="qxtsignalwaiter.html#QxtSignalWaiter">QxtSignalWaiter</a></b> ( const QObject * <i>sender</i>, const char * <i>signal</i> )</li>
<li><div class="fn"></div>bool <b><a href="qxtsignalwaiter.html#hasCapturedSignal">hasCapturedSignal</a></b> () const</li>
<li><div class="fn"></div>bool <b><a href="qxtsignalwaiter.html#wait-2">wait</a></b> ( int <i>msec</i> = -1, QEventLoop::ProcessEventsFlags <i>flags</i> = QEventLoop::AllEvents )</li>
</ul>
<ul>
<li><div class="fn"></div>29 public functions inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"></div>void <b><a href="qxtsignalwaiter.html#cancelWait">cancelWait</a></b> ()</li>
<li><div class="fn"></div>void <b><a href="qxtsignalwaiter.html#signalCaught">signalCaught</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"></div>1 public slot inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-slots">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"></div>bool <b><a href="qxtsignalwaiter.html#wait">wait</a></b> ( const QObject * <i>sender</i>, const char * <i>signal</i>, int <i>msec</i> = -1, QEventLoop::ProcessEventsFlags <i>flags</i> = QEventLoop::AllEvents )</li>
</ul>
<ul>
<li><div class="fn"></div>4 static public members inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>1 property inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#properties">QObject</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#signals">QObject</a></li>
<li><div class="fn"></div>1 public type inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-variables">QObject</a></li>
<li><div class="fn"></div>7 protected functions inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"></div>2 protected variables inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#protected-variables">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QxtSignalWaiter class blocks and processes events until a signal is emitted</p>
<p>In many cases, writing code that assumes certain actions are synchronous is considerably simpler than breaking your function into multiple blocks and using signals and slots to connect them all. Using this class, QSignalWaiter::wait will block until a certain signal is emitted and then return. The return value is true if the signal was caught, or false if a user-specified timeout elapses before catching the signal.</p>
<pre>    void MyObject::myFunction() {
        QxtSignalWaiter waiter(myOtherObject, SIGNAL(longProcessFinished()));
        myOtherObject-&gt;longProcess();
        if(waiter.wait(5000)) {
            doSomething(myOtherObject-&gt;information());
        } else {
            QMessageBox::information(0, &quot;MyObject&quot;, &quot;Timed out while waiting on longProcessFinished()&quot;, QMessageBox::Ok);
        }
    }</pre>
<p><b>Note:</b> QxtSignalWaiter is not reentrant. In particular, only one QxtSignalWaiter object per thread can be safely waiting at a time. If a second QxtSignalWaiter is used while the first is waiting, the first will not return until the second has timed out or successfully caught its signal.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QxtSignalWaiter"></a>QxtSignalWaiter::QxtSignalWaiter ( const <a href="http://doc.qtsoftware.com/4.5/qobject.html">QObject</a> * <i>sender</i>, const char * <i>signal</i> )</h3>
<p>Constructs a <a href="qxtsignalwaiter.html">QxtSignalWaiter</a> that will wait for <i>signal</i> from <i>sender</i> ie. sender::signal() to be emitted. <a href="qxtsignalwaiter.html">QxtSignalWaiter</a> objects are intended to be created on the stack, therefore no parent parameter is accepted.</p>
<h3 class="fn"><a name="cancelWait"></a>void QxtSignalWaiter::cancelWait ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>Signals a waiting object to stop blocking because the timeout has elapsed. <a href="qxtsignalwaiter.html#hasCapturedSignal">QxtSignalWaiter::hasCapturedSignal</a>() will return false after this slot is invoked. Use this slot to allow <a href="qxtsignalwaiter.html">QxtSignalWaiter</a> to be interrupted for reasons other than a timeout.</p>
<h3 class="fn"><a name="hasCapturedSignal"></a>bool QxtSignalWaiter::hasCapturedSignal () const</h3>
<p>Returns <tt>true</tt> if the desired signal was emitted during the last <a href="qxtsignalwaiter.html#wait">wait</a>() call.</p>
<h3 class="fn"><a name="signalCaught"></a>void QxtSignalWaiter::signalCaught ()&nbsp;&nbsp;<tt> [slot]</tt></h3>
<p>Signals a waiting object to stop blocking because the desired signal was emitted. <a href="qxtsignalwaiter.html#hasCapturedSignal">QxtSignalWaiter::hasCapturedSignal</a>() will return true after this slot is invoked. Use this slot to allow <a href="qxtsignalwaiter.html">QxtSignalWaiter</a> to wait for the first of multiple signals.</p>
<h3 class="fn"><a name="wait"></a>bool QxtSignalWaiter::wait ( const <a href="http://doc.qtsoftware.com/4.5/qobject.html">QObject</a> * <i>sender</i>, const char * <i>signal</i>, int <i>msec</i> = -1, <a href="http://doc.qtsoftware.com/4.5/qeventloop.html#ProcessEventsFlags-typedef">QEventLoop::ProcessEventsFlags</a> <i>flags</i> = QEventLoop::AllEvents )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded function provided for convenience. This version can be invoked without first instantiating a <a href="qxtsignalwaiter.html">QxtSignalWaiter</a> object. Waits for <i>signal</i> from <i>sender</i> to be emitted within <i>msec</i> while processing events according to <i>flags</i>. Returns <tt>true</tt> if the signal was caught, or <tt>false</tt> if the timeout elapsed.</p>
<h3 class="fn"><a name="wait-2"></a>bool QxtSignalWaiter::wait ( int <i>msec</i> = -1, <a href="http://doc.qtsoftware.com/4.5/qeventloop.html#ProcessEventsFlags-typedef">QEventLoop::ProcessEventsFlags</a> <i>flags</i> = QEventLoop::AllEvents )</h3>
<p>Blocks the current function until sender::signal() is emitted. If msec is not -1, <a href="qxtsignalwaiter.html#wait">wait</a>() will return before the signal is emitted if the specified number of milliseconds have elapsed. Returns <tt>true</tt> if the signal was caught, or <tt>false</tt> if the timeout elapsed. Note that <a href="qxtsignalwaiter.html#wait">wait</a>() may continue to block after the signal is emitted or the timeout elapses; the function only guarantees that it will not return BEFORE one of these conditions has occurred. This function is not reentrant.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td align="left">Copyright &copy; 2007-2010
<a href="mailto:foundation@libqxt.org">Qxt Foundation</a></td>
<td align="right"><div align="right">
<a href="http://libqxt.org">Qxt</a> 0.6.1</div></td>
</tr></table></div></address></body>
</html>