Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
signalsandslots.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
5
6//! [0]
7void Counter::setValue(int value)
8{
9 if (value != m_value) {
10 m_value = value;
11 emit valueChanged(value);
12 }
13}
14//! [0]
15
16int main()
17{
18//! [1]
19 Counter a, b;
20//! [1] //! [2]
21 QObject::connect(&a, &Counter::valueChanged,
22 &b, &Counter::setValue);
23//! [2]
24
25//! [3]
26 a.setValue(12); // a.value() == 12, b.value() == 12
27//! [3] //! [4]
28 b.setValue(48); // a.value() == 12, b.value() == 48
29//! [4]
30}
int main()
[open]
#define Counter
[0]