QBasicTimer 类为对象提供计时器事件。 更多...
头: | #include <QBasicTimer> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
QBasicTimer () | |
QBasicTimer (QBasicTimer && other ) | |
~QBasicTimer () | |
bool | isActive () const |
void | start (std::chrono::milliseconds duration , QObject * object ) |
void | start (std::chrono::milliseconds duration , Qt::TimerType timerType , QObject * obj ) |
void | stop () |
void | swap (QBasicTimer & other ) |
int | timerId () const |
QBasicTimer & | operator= (QBasicTimer && other ) |
void | swap (QBasicTimer & lhs , QBasicTimer & rhs ) |
这是用于 Qt 内部的快速、轻量、低级类。推荐使用更高级的 QTimer class rather than this class if you want to use timers in your applications. Note that this timer is a repeating timer that will send subsequent timer events unless the stop () 函数被调用。
To use this class, create a QBasicTimer, and call its start() function with a timeout interval and with a pointer to a
QObject
subclass. When the timer times out it will send a timer event to the
QObject
subclass. The timer can be stopped at any time using
stop
().
isActive
() 返回
true
for a timer that is running; i.e. it has been started, has not reached the timeout time, and has not been stopped. The timer's ID can be retrieved using
timerId
().
Objects of this class cannot be copied, but can be moved, so you can maintain a list of basic timers by holding them in container that supports move-only types, e.g. std::vector.
另请参阅 QTimer , QTimerEvent , QObject::timerEvent (), 计时器 ,和 仿射变换 .
[constexpr noexcept]
QBasicTimer::
QBasicTimer
()
Constructs a basic timer.
另请参阅 start ().
[noexcept]
QBasicTimer::
QBasicTimer
(
QBasicTimer
&&
other
)
Move-constructs a basic timer from other , which is left inactive .
[noexcept]
QBasicTimer::
~QBasicTimer
()
销毁基本计时器。
[noexcept]
bool
QBasicTimer::
isActive
() const
返回
true
if the timer is running and has not been stopped; otherwise returns
false
.
[since 6.5]
void
QBasicTimer::
start
(
std::chrono::milliseconds
duration
,
QObject
*
object
)
Starts (or restarts) the timer with a duration timeout. The timer will be a Qt::CoarseTimer 。见 Qt::TimerType for information on the different timer types.
给定 object 将接收计时器事件。
该函数在 Qt 6.5 引入。
另请参阅 stop (), isActive (), QObject::timerEvent (),和 Qt::CoarseTimer .
[since 6.5]
void
QBasicTimer::
start
(
std::chrono::milliseconds
duration
,
Qt::TimerType
timerType
,
QObject
*
obj
)
Starts (or restarts) the timer with a duration timeout and the given timerType 。见 Qt::TimerType for information on the different timer types.
obj 将接收计时器事件。
该函数在 Qt 6.5 引入。
另请参阅 stop (), isActive (), QObject::timerEvent (),和 Qt::TimerType .
停止计时器。
[noexcept]
void
QBasicTimer::
swap
(
QBasicTimer
&
other
)
Swaps the timer other with this timer. This operation is very fast and never fails.
[noexcept]
int
QBasicTimer::
timerId
() const
返回计时器 ID。
另请参阅 QTimerEvent::timerId ().
[noexcept]
QBasicTimer
&QBasicTimer::
operator=
(
QBasicTimer
&&
other
)
移动赋值 other to this basic timer. The timer previously represented by this basic timer is stopped. other is left as inactive .
另请参阅 stop (), isActive (),和 swap ().
[noexcept]
void
swap
(
QBasicTimer
&
lhs
,
QBasicTimer
&
rhs
)
Swaps the timer lhs with rhs 。此操作非常快且从不失败。