QBasicTimer 類為對象提供計時器事件。 更多...
| 頭: |
#include <QBasicTimer>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|
| qmake: |
QT += core
|
| Duration |
| QBasicTimer () | |
| QBasicTimer (QBasicTimer && other ) | |
| ~QBasicTimer () | |
(從 6.8 起)
Qt::TimerId
|
id () const |
| bool | isActive () const |
(從 6.5 起)
void
|
start (QBasicTimer::Duration duration , QObject * object ) |
(從 6.5 起)
void
|
start (QBasicTimer::Duration 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 () 函數被調用。
要使用此類,創建 QBasicTimer 並調用其
start
() 函數按超時間隔和采用指針指嚮
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 (), 計時器 ,和 仿射變換 .
[alias]
QBasicTimer::
Duration
A
std::chrono::duration
type that is used in various API in this class. This type exists to facilitate a possible transition to a higher or lower granularity.
在所有當前平颱,它是
nanoseconds
.
[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
(
QBasicTimer::Duration
duration
,
QObject
*
object
)
啓動 (或重啓) 計時器按 duration timeout. The timer will be a Qt::CoarseTimer 。見 Qt::TimerType 瞭解不同計時器類型的有關信息。
給定 object 將接收計時器事件。
從 Qt 6.10 開始,設置負間隔會導緻運行時警告,且值被重置為 1ms。在 Qt 6.10 之前,Qt 計時器允許設置負間隔,但行為方式齣人意料 (例如:停止計時器,若在運行或根本未啓動)。
注意: Starting from Qt 6.9 this method takes std::chrono::nanoseconds, before that it took std::chrono::milliseconds. This change is backwards compatible.
該函數在 Qt 6.5 引入。
另請參閱 stop (), isActive (), QObject::timerEvent (),和 Qt::CoarseTimer .
[since 6.5]
void
QBasicTimer::
start
(
QBasicTimer::Duration
duration
,
Qt::TimerType
timerType
,
QObject
*
obj
)
啓動 (或重啓) 計時器按 duration timeout and the given timerType 。見 Qt::TimerType 瞭解不同計時器類型的有關信息。
從 Qt 6.10 開始,設置負間隔會導緻運行時警告,且值被重置為 1ms。在 Qt 6.10 之前,Qt 計時器允許設置負間隔,但行為方式齣人意料 (例如:停止計時器,若在運行或根本未啓動)。
obj 將接收計時器事件。
注意: Starting from Qt 6.9 this method takes std::chrono::nanoseconds, before that it took std::chrono::milliseconds. This change is backwards compatible.
這是重載函數。
該函數在 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 。此操作很快且從不失敗。