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
4
#
include
"signalsandslots.h"
5
6
//! [0]
7
void
Counter
::setValue(
int
value)
8
{
9
if
(value != m_value) {
10
m_value = value;
11
emit valueChanged(value);
12
}
13
}
14
//! [0]
15
16
int
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
}
main
int main()
[open]
Definition
doc_src_objecttrees.cpp:7
Counter
#define Counter
[0]
Definition
signalsandslots.h:7
qtbase
src
corelib
doc
snippets
signalsandslots
signalsandslots.cpp
Generated on
for Qt by
1.14.0