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
qbasictimer.h
Go to the documentation of this file.
1
// Copyright (C) 2020 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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QBASICTIMER_H
6
#
define
QBASICTIMER_H
7
8
#
include
<
QtCore
/
qglobal
.
h
>
9
#
include
<
QtCore
/
qabstracteventdispatcher
.
h
>
10
#
include
<
QtCore
/
qnamespace
.
h
>
11
12
#
include
<
chrono
>
13
14
QT_BEGIN_NAMESPACE
15
16
17
class
QObject;
18
19
class
Q_CORE_EXPORT
QBasicTimer
20
{
21
Qt::TimerId m_id;
22
Q_DISABLE_COPY(QBasicTimer)
23
24
public
:
25
// use the same duration type
26
using
Duration = QAbstractEventDispatcher::Duration;
27
28
constexpr
QBasicTimer()
noexcept
: m_id{Qt::TimerId::Invalid} {}
29
~QBasicTimer() {
if
(isActive()) stop(); }
30
31
QBasicTimer(QBasicTimer &&other)
noexcept
32
: m_id{std::exchange(other.m_id, Qt::TimerId::Invalid)}
33
{}
34
35
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QBasicTimer)
36
37
void
swap(QBasicTimer &other)
noexcept
{ std::swap(m_id, other.m_id); }
38
39
bool
isActive()
const
noexcept
{
return
m_id != Qt::TimerId::Invalid; }
40
int
timerId()
const
noexcept
{
return
qToUnderlying(id()); }
41
Qt::TimerId id()
const
noexcept
{
return
m_id; }
42
QT_CORE_INLINE_SINCE(6, 5)
43
void
start(
int
msec, QObject *obj);
44
QT_CORE_INLINE_SINCE(6, 5)
45
void
start(
int
msec, Qt::TimerType timerType, QObject *obj);
46
47
#
if
QT_CORE_REMOVED_SINCE
(
6
,
9
)
48
void
start(std::chrono::milliseconds duration, QObject *obj);
49
void
start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj);
50
#
endif
51
void
start(Duration duration, QObject *obj)
52
{ start(duration, Qt::CoarseTimer, obj); }
53
void
start(Duration duration, Qt::TimerType timerType, QObject *obj);
54
void
stop();
55
};
56
Q_DECLARE_TYPEINFO
(QBasicTimer, Q_RELOCATABLE_TYPE);
57
58
#
if
QT_CORE_INLINE_IMPL_SINCE
(
6
,
5
)
59
void
QBasicTimer::start(
int
msec, QObject *obj)
60
{
61
start(std::chrono::milliseconds{msec}, obj);
62
}
63
64
void
QBasicTimer::start(
int
msec, Qt::TimerType t, QObject *obj)
65
{
66
start(std::chrono::milliseconds{msec}, t, obj);
67
}
68
#
endif
69
70
inline
void
swap
(QBasicTimer &lhs, QBasicTimer &rhs)
noexcept
{ lhs.swap(rhs); }
71
72
QT_END_NAMESPACE
73
74
#
endif
// QBASICTIMER_H
QBasicTimer
\inmodule QtCore
Definition
qbasictimer.h:20
swap
void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept
Definition
qbasictimer.h:70
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
qtbase
src
corelib
kernel
qbasictimer.h
Generated on
for Qt by
1.18.0