summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/timers/timers.cpp
blob: c89db6890c71eb17566df6b554daaf59af777521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QTimer>

class Foo : public QObject
{
public:
    Foo();
};

Foo::Foo()
{
//! [0]
    QTimer *timer = new QTimer(this);
//! [0] //! [1]
    connect(timer, &QTimer::timeout, this, &Foo::updateCaption);
//! [1] //! [2]
    timer->start(1000);
//! [2]

//! [3]
    QTimer::singleShot(200, this, &Foo::updateCaption);
//! [3]

    {
    // ZERO-CASE
//! [4]
    QTimer *timer = new QTimer(this);
//! [4] //! [5]
    connect(timer, &QTimer::timeout, this, &Foo::processOneThing);
//! [5] //! [6]
    timer->start();
//! [6]
    }
}

int main()
{

}