Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
timers.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QChronoTimer>
5#include <QObject>
6#include <QTimer>
7
8using namespace std::chrono;
9
10class Foo : public QObject
11{
12public:
13 Foo();
14};
15
17{
19 QTimer *timer = new QTimer(this);
21 connect(timer, &QTimer::timeout, this, &Foo::updateCaption);
23 timer->start(1000);
25
27 QTimer::singleShot(200, this, &Foo::updateCaption);
29
30 {
31 // ZERO-CASE
33 QTimer *timer = new QTimer(this);
35 connect(timer, &QTimer::timeout, this, &Foo::processOneThing);
37 timer->start();
39 }
40}
41
42// QChronoTimer
43class MyWidget : QObject
44{
45 MyWidget()
46 {
49 QChronoTimer::singleShot(200ms, &widget, &MyWidget::updateCaption);
51
53 // The default interval is 0ns
54 QChronoTimer *timer = new QChronoTimer(this);
56 timer->start();
58
59 {
61 QChronoTimer *timer = new QChronoTimer(1s, this);
63 timer->start();
65 }
66
67 {
69 QChronoTimer *timer = new QChronoTimer(this);
72 timer->start();
74 }
75 }
76
77public Q_SLOTS:
79};
80
81int main()
82{
83}
Foo()
Definition timers.cpp:16
void processOneThing()
\inmodule QtCore
bool singleShot
Whether the timer is a single-shot timer.
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore
Definition qtimer.h:20
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:241
void setInterval(int msec)
Definition qtimer.cpp:579
bool singleShot
whether the timer is a single-shot timer
Definition qtimer.h:22
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
QOpenGLWidget * widget
[1]
GLdouble s
[6]
Definition qopenglext.h:235
#define Q_SLOTS
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QTimer * timer
[3]
int main()
Definition timers.cpp:81