QTimer Class ReferenceThe QTimer class provides timer signals and single-shot timers. More... #include <qtimer.h> Inherits QObject. Public Members
Signals
Static Public Members
Detailed DescriptionThe QTimer class provides timer signals and single-shot timers.
It 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. When the time is up it will emit the timeout() signal. Note that a QTimer object is destroyed automatically when its parent object is destroyed. Example: QTimer *timer = new QTimer( myObject ); connect( timer, SIGNAL(timeout()), myObject, SLOT(timerDone()) ); timer->start( 2000, TRUE ); // 2 seconds single-shot timer You can also use the static singleShot() function to create a single shot timer. 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. This can be used to do heavy work while providing a snappy user interface: QTimer *t = new QTimer( myObject ); connect( t, SIGNAL(timeout()), SLOT(processOneThing()) ); t->start( 0, FALSE ); 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. 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. An 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. Some operating systems limit the number of timers that may be used; Qt tries to work around these limitations. See also Event Classes and Time and Date. Member Function Documentation
Constructs a timer called name, with the parent parent.
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Quarterly au hasardSe brancher au WebQt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com