Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1958

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qtimer.cpp:42 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QTimer Class</title>
<style type="text/css"><!--
h3.fn,span.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>QTimer Class Reference</h1>

<p>The QTimer class provides timer signals and single-shot timers.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qtimer-h.html">qtimer.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p><a href="qtimer-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QTimer"><b>QTimer</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn><a href="#~QTimer"><b>~QTimer</b></a> ()</div></li>
<li><div class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</div></li>
<li><div class=fn>int <a href="#start"><b>start</b></a> ( int&nbsp;msec, bool&nbsp;sshot = FALSE )</div></li>
<li><div class=fn>void <a href="#changeInterval"><b>changeInterval</b></a> ( int&nbsp;msec )</div></li>
<li><div class=fn>void <a href="#stop"><b>stop</b></a> ()</div></li>
</ul>
<h2>Signals</h2>
<ul>
<li><div class=fn>void <a href="#timeout"><b>timeout</b></a> ()</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>void <a href="#singleShot"><b>singleShot</b></a> ( int&nbsp;msec, QObject&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QTimer class provides timer signals and single-shot timers.
<p> 


<p> It uses <a href="qtimerevent.html">timer events</a> internally to provide a
more versatile timer.	 QTimer is very easy to use: create a QTimer, call
<a href="#start">start</a>() to start it and connect its <a href="#timeout">timeout</a>() to the appropriate slots.
When the time is up it will emit the timeout() signal.
<p> Note that a QTimer object is destroyed automatically when its parent
object is destroyed.
<p> Example:
<pre>
    QTimer *timer = new QTimer( myObject );
    <a href="qobject.html#connect">connect</a>( timer, SIGNAL(<a href="#timeout">timeout</a>()), myObject, SLOT(timerDone()) );
    timer-&gt;<a href="#start">start</a>( 2000, TRUE ); // 2 seconds single-shot timer
  </pre>
 
<p> You can also use the static <a href="#singleShot">singleShot</a>() function to create a single
shot timer.
<p> As a special case, a QTimer with timeout 0 times out as soon as all
the events in the window system's event queue have been processed.
<p> This can be used to do heavy work while providing a snappy
user interface:
<pre>
    QTimer *t = new QTimer( myObject );
    <a href="qobject.html#connect">connect</a>( t, SIGNAL(<a href="#timeout">timeout</a>()), SLOT(processOneThing()) );
    t-&gt;<a href="#start">start</a>( 0, FALSE );
  </pre>
 
<p> myObject->processOneThing() will be called repeatedly and should
return quickly (typically after processing one data item) so that Qt
can deliver events to widgets and stop the timer as soon as it has
done all its work.  This is the traditional way of implementing heavy
work in GUI applications; multi-threading is now becoming available
on more and more platforms, and we expect that null events will
eventually be replaced by threading.
<p> Note that QTimer's accuracy depends on the underlying operating
system and hardware.  Most platforms support an accuracy of 20ms;
some provide more.  If Qt is unable to deliver the requested number
of timer clicks, it will silently discard some.
<p> An alternative to using QTimer is to call <a href="qobject.html#startTimer">QObject::startTimer</a>() for
your object and reimplement the <a href="qobject.html#timerEvent">QObject::timerEvent</a>() event handler
in your class (which must, of course, inherit <a href="qobject.html">QObject</a>).  The
disadvantage is that <a href="qobject.html#timerEvent">timerEvent</a>() does not support such high-level
features as single-shot timers or signals.
<p> Some operating systems limit the number of timers that may be used;
Qt tries to work around these limitations.
<p>See also <a href="events.html">Event Classes</a> and <a href="time.html">Time and Date</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QTimer"></a>QTimer::QTimer ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs a timer with a <em>parent</em> and a <em>name</em>.
<p> Note that the destructor of the parent object will destroy this timer
object.

<h3 class=fn><a name="~QTimer"></a>QTimer::~QTimer ()
</h3>
Destroys the timer.

<h3 class=fn>void <a name="changeInterval"></a>QTimer::changeInterval ( int&nbsp;msec )
</h3>
Changes the timeout interval to <em>msec</em> milliseconds.
<p> If the timer signal is pending, it will be stopped and restarted;
otherwise it will be started.
<p> <p>See also <a href="#start">start</a>() and <a href="#isActive">isActive</a>().

<h3 class=fn>bool <a name="isActive"></a>QTimer::isActive () const
</h3>

Returns TRUE if the timer is running (pending) or FALSE if the timer is
idle.

<p>Example: <a href="t11.html#x2189">t11/cannon.cpp</a>.
<h3 class=fn>void <a name="singleShot"></a>QTimer::singleShot ( int&nbsp;msec, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;receiver, const&nbsp;char&nbsp;*&nbsp;member )<tt> [static]</tt>
</h3>
This static function calls a slot after a given time interval.
<p> It is very convenient to use this function because you do not need to
bother with a <a href="qobject.html#timerEvent">timerEvent</a> or to
create a local QTimer object.
<p> Example:
<pre>
    #include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
    #include &lt;<a href="qtimer-h.html">qtimer.h</a>&gt;

    int main( int argc, char **argv )
    {
        <a href="qapplication.html">QApplication</a> a( argc, argv );
        QTimer::<a href="#singleShot">singleShot</a>( 10*60*1000, &amp;a, SLOT(<a href="qapplication.html#quit">quit</a>()) );
            ... // create and show your widgets
        return a.<a href="qapplication.html#exec">exec</a>();
    }
  </pre>
 
<p> This sample program automatically terminates after 10 minutes (i.e.
600000 milliseconds).
<p> The <em>receiver</em> is the receiving object and the <em>member</em> is the
slot. The time interval is <em>msec</em>.

<h3 class=fn>int <a name="start"></a>QTimer::start ( int&nbsp;msec, bool&nbsp;sshot = FALSE )
</h3>
Starts the timer with an <em>msec</em> milliseconds timeout.
<p> If <em>sshot</em> is TRUE, the timer will be activated only once;
otherwise it will continue until it is stopped.
<p> Any pending timer will be stopped.
<p> <p>See also <a href="#singleShot">singleShot</a>(), <a href="#stop">stop</a>(), <a href="#changeInterval">changeInterval</a>() and <a href="#isActive">isActive</a>().

<p>Examples: <a href="aclock-example.html#x2079">aclock/aclock.cpp</a>, <a href="dirview-example.html#x1698">dirview/dirview.cpp</a>, <a href="forever-example.html#x1486">forever/forever.cpp</a>, <a href="hello-example.html#x1466">hello/hello.cpp</a>, <a href="t11.html#x2190">t11/cannon.cpp</a> and <a href="t13.html#x2220">t13/cannon.cpp</a>.
<h3 class=fn>void <a name="stop"></a>QTimer::stop ()
</h3>
Stops the timer.
<p>See also <a href="#start">start</a>().

<p>Examples: <a href="dirview-example.html#x1699">dirview/dirview.cpp</a>, <a href="t11.html#x2191">t11/cannon.cpp</a>, <a href="t12.html#x2213">t12/cannon.cpp</a> and <a href="t13.html#x2221">t13/cannon.cpp</a>.
<h3 class=fn>void <a name="timeout"></a>QTimer::timeout ()<tt> [signal]</tt>
</h3>

This signal is emitted when the timer is activated.

<p>Examples: <a href="aclock-example.html#x2080">aclock/aclock.cpp</a>, <a href="dirview-example.html#x1700">dirview/dirview.cpp</a>, <a href="forever-example.html#x1487">forever/forever.cpp</a>, <a href="hello-example.html#x1467">hello/hello.cpp</a> and <a href="t11.html#x2192">t11/cannon.cpp</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<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; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>