summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/signalsandslots/signalsandslots.h
blob: 2f5a53231c87a8de55e12f6f80793342fd13ab7d (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
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef SIGNALSANDSLOTS_H
#define SIGNALSANDSLOTS_H

#define Counter PlainCounter

//! [0]
class Counter
{
public:
    Counter() { m_value = 0; }

    int value() const { return m_value; }
    void setValue(int value);

private:
    int m_value;
};
//! [0]

#undef Counter
#define Counter ObjectCounter

//! [1]
#include <QObject>
//! [1]

//! [2]
class Counter : public QObject
//! [2] //! [3]
{
    Q_OBJECT

public:
    Counter() { m_value = 0; }

    int value() const { return m_value; }

public slots:
    void setValue(int value);

signals:
    void valueChanged(int newValue);

private:
    int m_value;
};
//! [3]

#endif