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 () | |
(從 6.8 起)
Qt::TimerId
|
id () const |
| bool | isActive () const |
(從 6.5 起)
void
|
start (std::chrono::milliseconds duration , QObject * object ) |
(從 6.5 起)
void
|
start (std::chrono::milliseconds duration , Qt::TimerType timerType , QObject * obj ) |
| void | stop () |
| void | swap (QBasicTimer & other ) |
| QBasicTimer & | operator= (QBasicTimer && other ) |
| void | swap (QBasicTimer & lhs , QBasicTimer & rhs ) |
這是用於 Qt 內部的快速、輕量、低級類。推薦使用更高級 QTimer 類而不是此類,若想要在應用程序中使用計時器。注意,該計時器是將發送後續計時器事件的重復計時器,除非 stop () 函數被調用。
To use this class, create a QBasicTimer, and call its start() function with a timeout interval and with a pointer to a
QObject
子類。當超時時,計時器會將計時器事件發送給
QObject
子類。可以在任何時候停止計時器,使用
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().
此類的對象無法拷貝,但可以移動,因此,可以通過將基本計時器保存在支持僅移動類型 (如 std::vector) 的容器中來維護它們的列錶。
另請參閱 QTimer , QChronoTimer , QTimerEvent , QObject::timerEvent (), 計時器 ,和 仿射變換 .
[constexpr noexcept]
QBasicTimer::
QBasicTimer
()
構造基本計時器。
另請參閱 start ().
[noexcept]
QBasicTimer::
QBasicTimer
(
QBasicTimer
&&
other
)
移動構造基本計時器從 other ,其保持 inactive .
[noexcept]
QBasicTimer::
~QBasicTimer
()
銷毀基本計時器。
[noexcept, since 6.8]
Qt::TimerId
QBasicTimer::
id
() const
返迴計時器 ID。
該函數在 Qt 6.8 引入。
另請參閱 QTimerEvent::id ().
[noexcept]
bool
QBasicTimer::
isActive
() const
返迴
true
若計時器在運行且尚未停止;否則返迴
false
.
[since 6.5]
void
QBasicTimer::
start
(
std::chrono::milliseconds
duration
,
QObject
*
object
)
啓動 (或重啓) 計時器按 duration timeout. The timer will be a Qt::CoarseTimer 。見 Qt::TimerType 瞭解不同計時器類型的有關信息。
給定 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
)
啓動 (或重啓) 計時器按 duration timeout and the given timerType 。見 Qt::TimerType 瞭解不同計時器類型的有關信息。
obj 將接收計時器事件。
該函數在 Qt 6.5 引入。
另請參閱 stop (), isActive (), QObject::timerEvent (),和 Qt::TimerType .
停止計時器。
[noexcept]
void
QBasicTimer::
swap
(
QBasicTimer
&
other
)
Swaps this timer with other 。此操作很快且從不失敗。
[noexcept]
QBasicTimer
&QBasicTimer::
operator=
(
QBasicTimer
&&
other
)
移動賦值 other 到此基本計時器。停止先前由此基本計時器錶示的計時器。 other 保持按 inactive .
另請參閱 stop (), isActive (),和 swap ().
[noexcept]
void
swap
(
QBasicTimer
&
lhs
,
QBasicTimer
&
rhs
)
交換計時器 lhs with rhs 。此操作很快且從不失敗。