⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtimer.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
字号:
'\" t.TH QTimer 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTimer \- Timer signals and single-shot timers.br.PP\fC#include <qtimer.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQTimer\fR ( QObject * " "parent" "=0, const char * " "name" "=0 ) ".br.ti -1c.BI "\fB~QTimer\fR () ".br.ti -1c.BI "bool \fBisActive\fR () const".br.ti -1c.BI "int \fBstart\fR ( int " "msec" ", bool " "sshot" " = FALSE ) ".br.ti -1c.BI "void \fBchangeInterval\fR ( int msec ) ".br.ti -1c.BI "void \fBstop\fR () ".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBtimeout\fR () ".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "void \fBsingleShot\fR ( int " "msec" ", QObject * " "receiver" ", const char * member ) ".br.in -1c.SH DESCRIPTIONThe QTimer class provides timer signals and single-shot timers..PPIt uses timer events internally to provide a more versatile timer. QTimer is very easy to use, create a QTimer, call start() to start it and connect its timeout() to the appropriate slots, then when the time is up it will emit timeout()..PPNote that a QTimer object is destroyed automatically when its parent object is destroyed..PPExample:.PP.nf.br    QTimer *timer = new QTimer( myObject );.br    connect( timer, SIGNAL(timeout()),.br             myObject, SLOT(timerDone()) );.br    timer->start( 2000, TRUE );                 // 2 seconds single-shot.fi.PPAs 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..PPThis can be used to do heavy work while providing a snappy user interface:.PP.nf.br    QTimer *t = new QTimer( myObject );.br    connect( t, SIGNAL(timeout()), SLOT(processOneThing()) );.br    t->start( 0, FALSE );.fi.PPmyObject->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..PPNote 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..PPAn alternative to using QTimer is to call QObject::startTimer() for your object and reimplement the QObject::timerEvent() event handler in your class (which must of course inherit QObject). The disadvantage is that timerEvent() does not support such high-level features as single-shot timers or signals..PPExamples:.(lforever/forever.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QTimer::QTimer ( QObject * parent=0, const char * name=0 )"Constructs a timer with a \fIparent\fR and a \fIname.\fR.PPNotice that the destructor of the parent object will destroy this timer object..SH "QTimer::~QTimer ()"Destructs the timer..SH "void QTimer::changeInterval ( int msec )"Changes the timeout interval to \fImsec\fR milliseconds..PPIf the timer signal is pending, it will be stopped and restarted, otherwise it will be started..PPSee also start() and isActive()..SH "bool QTimer::event ( QEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QObject..SH "bool QTimer::isActive () const"Returns TRUE if the timer is running (pending), or FALSE is the timer is idle..SH "void QTimer::singleShot ( int msec, QObject * receiver, const char * member ) \fC[static]\fR"This static function calls a slot after a given time interval..PPIt is very convenient to use this function because you do not need to bother with a timerEvent or to create a local QTimer object..PPExample:.PP.nf.br    #include <qapplication.h>.br    #include <qtimer.h>.br.br    int main( int argc, char **argv ).br    {.br        QApplication a( argc, argv );.br        QTimer::singleShot( 10*60*1000, &a, SLOT(quit()) );.br            ... // create and show your widgets.br        return a.exec();.br    }.fi.PPThis sample program automatically terminates after 10 minutes (i.e. 600000 milliseconds)..SH "int QTimer::start ( int msec, bool sshot = FALSE )"Starts the timer with a \fImsecs\fR milliseconds timeout..PPIf \fIsshot\fR is TRUE, the timer will be activated only once, otherwise it will continue until it is stopped..PPAny pending timer will be stopped..PPSee also stop(), changeInterval() and isActive()..PPExamples:.(lforever/forever.cpp.)l.SH "void QTimer::stop ()"Stops the timer..PPSee also start()..SH "void QTimer::timeout () \fC[signal]\fR"This signal is emitted when the timer is activated..SH "SEE ALSO".BR http://doc.trolltech.com/qtimer.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qtimer.3qt) and the Qtversion (2.3.10).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -