Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsignalspy.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QSIGNALSPY_H
5
#
define
QSIGNALSPY_H
6
7
#
include
<
QtCore
/
qbytearray
.
h
>
8
#
include
<
QtCore
/
qlist
.
h
>
9
#
include
<
QtCore
/
qmetaobject
.
h
>
10
#
include
<
QtTest
/
qtesteventloop
.
h
>
11
#
include
<
QtCore
/
qvariant
.
h
>
12
#
include
<
QtCore
/
qmutex
.
h
>
13
14
#
include
<
memory
>
15
16
QT_BEGIN_NAMESPACE
17
18
19
class
QVariant;
20
class
QSignalSpyPrivate
;
21
class
QSignalSpy
:
public
QList
<
QList
<
QVariant
> >
22
{
23
struct
ObjectSignal {
24
const
QObject *obj;
25
QMetaMethod sig;
26
};
27
friend
class
QSignalSpyPrivate
;
28
std::unique_ptr<QSignalSpyPrivate> d_ptr;
29
public
:
30
explicit
QSignalSpy
(
const
QObject *obj,
const
char
*aSignal)
31
:
QSignalSpy
(verify(obj, aSignal)) {}
32
#
ifdef
Q_QDOC
33
template
<
typename
PointerToMemberFunction
>
34
QSignalSpy
(
const
QObject
*
object
,
PointerToMemberFunction
signal
);
35
#
else
36
template
<
typename
Func>
37
QSignalSpy
(
const
typename
QtPrivate
::
FunctionPointer
<
Func
>::
Object
*
obj
,
Func
signal0
)
38
:
QSignalSpy
(verify(obj, QMetaMethod::fromSignal(signal0))) {}
39
#
endif
// Q_QDOC
40
QSignalSpy
(
const
QObject *obj, QMetaMethod signal)
41
:
QSignalSpy
(verify(obj, signal)) {}
42
Q_TESTLIB_EXPORT
~
QSignalSpy
();
43
44
bool
isValid
()
const
noexcept
{
return
d_ptr !=
nullptr
; }
45
inline
QByteArray
signal
()
const
{
return
sig; }
46
47
bool
wait
(
int
timeout)
48
{
return
wait
(std::chrono::milliseconds{timeout}); }
49
50
Q_TESTLIB_EXPORT
bool
wait
(std::chrono::milliseconds timeout =
std
::
chrono
::
seconds
{5});
51
52
private
:
53
Q_TESTLIB_EXPORT
explicit
QSignalSpy
(
ObjectSignal
os
);
54
55
Q_TESTLIB_EXPORT
static
ObjectSignal
verify
(
const
QObject
*
obj
,
QMetaMethod
signal
);
56
Q_TESTLIB_EXPORT
static
ObjectSignal
verify
(
const
QObject
*
obj
,
const
char
*
aSignal
);
57
58
Q_TESTLIB_EXPORT
void
appendArgs(
void
**a);
59
60
// the full, normalized signal name
61
const
QByteArray sig;
62
// holds the QMetaType types for the argument list of the signal
63
const
QList<
int
> args;
64
65
QTestEventLoop m_loop;
66
bool
m_waiting =
false
;
67
QMutex m_mutex;
// protects m_waiting and the QList base class, between appendArgs() and wait()
68
};
69
70
QT_END_NAMESPACE
71
72
#
endif
QSignalSpyPrivate
Definition
qsignalspy.cpp:238
QSignalSpyPrivate::QSignalSpyPrivate
QSignalSpyPrivate(QSignalSpy *qq)
Definition
qsignalspy.cpp:241
QSignalSpyPrivate::qt_metacall
int qt_metacall(QMetaObject::Call call, int methodId, void **a) override
\reimp
Definition
qsignalspy.cpp:296
QSignalSpy
\inmodule QtTest
Definition
qsignalspy.h:22
QSignalSpy::QSignalSpy
QSignalSpy(const typename QtPrivate::FunctionPointer< Func >::Object *obj, Func signal0)
Definition
qsignalspy.h:37
QSignalSpy::wait
bool wait(int timeout)
Definition
qsignalspy.h:47
QSignalSpy::QSignalSpy
QSignalSpy(const QObject *obj, const char *aSignal)
Constructs a new QSignalSpy that listens for emissions of the signal from the QObject object.
Definition
qsignalspy.h:30
QSignalSpy::isValid
bool isValid() const noexcept
Returns true if the signal spy listens to a valid signal, otherwise false.
Definition
qsignalspy.h:44
QSignalSpy::~QSignalSpy
Q_TESTLIB_EXPORT ~QSignalSpy()
Destructor.
QSignalSpy::signal
QByteArray signal() const
Returns the normalized signal the spy is currently listening to.
Definition
qsignalspy.h:45
QSignalSpy::QSignalSpy
QSignalSpy(const QObject *obj, QMetaMethod signal)
Definition
qsignalspy.h:40
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
isSignalMetaMethodValid
static bool isSignalMetaMethodValid(QMetaMethod signal)
Definition
qsignalspy.cpp:160
isObjectValid
static bool isObjectValid(const QObject *object)
Definition
qsignalspy.cpp:175
makeArgs
static QList< int > makeArgs(QMetaMethod member)
Definition
qsignalspy.cpp:219
qtbase
src
testlib
qsignalspy.h
Generated on
for Qt by
1.18.0