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
qeventspy.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
QEVENTSPY_H
5
#
define
QEVENTSPY_H
6
7
#
include
<
QtTest
/
qttestglobal
.
h
>
8
#
include
<
QtCore
/
qcoreevent
.
h
>
9
#
include
<
QtCore
/
qlist
.
h
>
10
11
#
include
<
functional
>
12
#
include
<
memory
>
13
14
QT_BEGIN_NAMESPACE
15
16
class
QObject;
17
class
QEventSpyPrivate;
18
19
class
QEventSpy
20
{
21
public
:
22
using
Filter
=
std
::function<
bool
(QObject *receiver,
const
QEvent *event)>;
23
24
Q_TESTLIB_EXPORT
explicit
QEventSpy
(
QObject
*
object
);
25
Q_TESTLIB_EXPORT
QEventSpy
(
QObject
*
object
,
QEvent
::
Type
type
);
26
Q_TESTLIB_EXPORT
QEventSpy
(
QObject
*
object
,
const
QList
<
QEvent
::
Type
> &
types
);
27
Q_TESTLIB_EXPORT
QEventSpy
(
QObject
*
object
,
Filter
filter
);
28
Q_TESTLIB_EXPORT
~
QEventSpy
();
29
30
Q_TESTLIB_EXPORT
bool
isValid
()
const
noexcept
;
31
Q_TESTLIB_EXPORT QObject *
object
()
const
;
32
33
Q_TESTLIB_EXPORT qsizetype
count
()
const
noexcept
;
34
Q_TESTLIB_EXPORT
qsizetype
count
(
QEvent
::
Type
type
)
const
noexcept
;
35
qsizetype
size
()
const
noexcept
{
return
count(); }
36
bool
isEmpty
()
const
noexcept
{
return
count() == 0; }
37
bool
contains
(QEvent::Type type)
const
noexcept
{
return
count(type) > 0; }
38
39
Q_TESTLIB_EXPORT
QList
<
QEvent
::
Type
>
eventList
()
const
;
40
Q_TESTLIB_EXPORT
const
QEvent *
at
(
qsizetype
i
)
const
;
41
template
<
typename
EventType>
42
const
EventType *
at
(qsizetype i)
const
43
{
return
static_cast
<
const
EventType *>(at(i)); }
44
Q_TESTLIB_EXPORT
QObject
*
receiver
(
qsizetype
i
)
const
;
45
46
Q_TESTLIB_EXPORT
void
clear
();
47
48
private
:
49
Q_DISABLE_COPY_MOVE
(
QEventSpy
)
50
51
std::unique_ptr<QEventSpyPrivate> d_ptr;
52
};
53
54
QT_END_NAMESPACE
55
56
#
endif
// QEVENTSPY_H
QEventSpy
\inmodule QtTest
Definition
qeventspy.h:20
QEventSpy::isEmpty
bool isEmpty() const noexcept
Returns true if the spy has not recorded any events, otherwise false.
Definition
qeventspy.h:36
QEventSpy::Filter
std::function< bool(QObject *receiver, const QEvent *event)> Filter
A synonym for {std::function<bool(QObject *receiver, const QEvent *event)>}.
Definition
qeventspy.h:22
QEventSpy::at
const EventType * at(qsizetype i) const
Definition
qeventspy.h:42
QEventSpy::contains
bool contains(QEvent::Type type) const noexcept
Returns true if the spy has recorded at least one event of the given type, otherwise false.
Definition
qeventspy.h:37
QEventSpy::size
qsizetype size() const noexcept
Same as count().
Definition
qeventspy.h:35
QEventSpy::~QEventSpy
Q_TESTLIB_EXPORT ~QEventSpy()
Destroys the QEventSpy, and removes it as an event filter from the spied-on object.
QEventSpy::isValid
Q_TESTLIB_EXPORT bool isValid() const noexcept
Returns true if the spy was constructed with a valid object, otherwise false.
Definition
qeventspy.cpp:193
QEventSpy::clear
Q_TESTLIB_EXPORT void clear()
Removes all recorded events from the spy.
Definition
qeventspy.cpp:304
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtbase
src
testlib
qeventspy.h
Generated on
for Qt by
1.18.0