Struct qt_core::QDeadlineTimer

source ·
#[repr(C)]
pub struct QDeadlineTimer { /* private fields */ }
Expand description

The QDeadlineTimer class marks a deadline in the future.

C++ class: QDeadlineTimer.

C++ documentation:

The QDeadlineTimer class marks a deadline in the future.

The QDeadlineTimer class is usually used to calculate future deadlines and verify whether the deadline has expired. QDeadlineTimer can also be used for deadlines without expiration ("forever"). It forms a counterpart to QElapsedTimer, which calculates how much time has elapsed since QElapsedTimer::start() was called.

QDeadlineTimer provides a more convenient API compared to QElapsedTimer::hasExpired().

The typical use-case for the class is to create a QDeadlineTimer before the operation in question is started, and then use remainingTime() or hasExpired() to determine whether to continue trying the operation. QDeadlineTimer objects can be passed to functions being called to execute this operation so they know how long to still operate.

void executeOperation(int msecs) { QDeadlineTimer deadline(msecs); do { if (readFromDevice(deadline.remainingTime()) break; waitForReadyRead(deadline); } while (!deadline.hasExpired()); }

Many QDeadlineTimer functions deal with time out values, which all are measured in milliseconds. There are two special values, the same as many other Qt functions named waitFor or similar:

  • 0: no time left, expired
  • -1: infinite time left, timer never expires

Implementations§

source§

impl QDeadlineTimer

source

pub unsafe fn add_assign(&self, msecs: i64) -> Ref<QDeadlineTimer>

Extends this QDeadlineTimer object by msecs milliseconds and returns itself. If this object is set to never expire, this function does nothing.

Calls C++ function: QDeadlineTimer& QDeadlineTimer::operator+=(qint64 msecs).

C++ documentation:

Extends this QDeadlineTimer object by msecs milliseconds and returns itself. If this object is set to never expire, this function does nothing.

To add times of precision greater than 1 millisecond, use addNSecs().

source

pub unsafe fn add_n_secs( dt: impl CastInto<Ref<QDeadlineTimer>>, nsecs: i64 ) -> CppBox<QDeadlineTimer>

Returns a QDeadlineTimer object whose deadline is extended from dt's deadline by nsecs nanoseconds. If dt was set to never expire, this function returns a QDeadlineTimer that will not expire either.

Calls C++ function: static QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs).

C++ documentation:

Returns a QDeadlineTimer object whose deadline is extended from dt’s deadline by nsecs nanoseconds. If dt was set to never expire, this function returns a QDeadlineTimer that will not expire either.

Note: if dt was created as expired, its deadline is indeterminate and adding an amount of time may or may not cause it to become unexpired.

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QDeadlineTimer>> ) -> Ref<QDeadlineTimer>

The QDeadlineTimer class marks a deadline in the future.

Calls C++ function: QDeadlineTimer& QDeadlineTimer::operator=(const QDeadlineTimer& other).

C++ documentation:

The QDeadlineTimer class marks a deadline in the future.

The QDeadlineTimer class is usually used to calculate future deadlines and verify whether the deadline has expired. QDeadlineTimer can also be used for deadlines without expiration ("forever"). It forms a counterpart to QElapsedTimer, which calculates how much time has elapsed since QElapsedTimer::start() was called.

QDeadlineTimer provides a more convenient API compared to QElapsedTimer::hasExpired().

The typical use-case for the class is to create a QDeadlineTimer before the operation in question is started, and then use remainingTime() or hasExpired() to determine whether to continue trying the operation. QDeadlineTimer objects can be passed to functions being called to execute this operation so they know how long to still operate.

void executeOperation(int msecs) { QDeadlineTimer deadline(msecs); do { if (readFromDevice(deadline.remainingTime()) break; waitForReadyRead(deadline); } while (!deadline.hasExpired()); }

Many QDeadlineTimer functions deal with time out values, which all are measured in milliseconds. There are two special values, the same as many other Qt functions named waitFor or similar:

  • 0: no time left, expired
  • -1: infinite time left, timer never expires
source

pub unsafe fn current_1a(timer_type: TimerType) -> CppBox<QDeadlineTimer>

Returns a QDeadlineTimer that is expired but is guaranteed to contain the current time. Objects created by this function can participate in the calculation of how long a timer is overdue, using the deadline() function.

Calls C++ function: static QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType = …).

C++ documentation:

Returns a QDeadlineTimer that is expired but is guaranteed to contain the current time. Objects created by this function can participate in the calculation of how long a timer is overdue, using the deadline() function.

The QDeadlineTimer object will be constructed with the specified timerType.

source

pub unsafe fn current_0a() -> CppBox<QDeadlineTimer>

Returns a QDeadlineTimer that is expired but is guaranteed to contain the current time. Objects created by this function can participate in the calculation of how long a timer is overdue, using the deadline() function.

Calls C++ function: static QDeadlineTimer QDeadlineTimer::current().

C++ documentation:

Returns a QDeadlineTimer that is expired but is guaranteed to contain the current time. Objects created by this function can participate in the calculation of how long a timer is overdue, using the deadline() function.

The QDeadlineTimer object will be constructed with the specified timerType.

source

pub unsafe fn deadline(&self) -> i64

Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in milliseconds relative to the reference clock, the same as QElapsedTimer::msecsSinceReference(). The value will be in the past if this QDeadlineTimer has expired.

Calls C++ function: qint64 QDeadlineTimer::deadline() const.

C++ documentation:

Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in milliseconds relative to the reference clock, the same as QElapsedTimer::msecsSinceReference(). The value will be in the past if this QDeadlineTimer has expired.

If this QDeadlineTimer never expires, this function returns std::numeric_limits<qint64>::max().

This function can be used to calculate the amount of time a timer is overdue, by subtracting QDeadlineTimer::current() or QElapsedTimer::msecsSinceReference(), as in the following example:

qint64 realTimeLeft = deadline.deadline(); if (realTimeLeft != (std::numeric_limits<qint64>::max)()) { realTimeLeft -= QDeadlineTimer::current().deadline(); // or: //QElapsedTimer timer; //timer.start(); //realTimeLeft -= timer.msecsSinceReference(); }

Note: Timers that were created as expired have an indetermine time point in the past as their deadline, so the above calculation may not work.

See also remainingTime(), deadlineNSecs(), and setDeadline().

source

pub unsafe fn deadline_n_secs(&self) -> i64

Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in nanoseconds relative to the reference clock, the same as QElapsedTimer::msecsSinceReference(). The value will be in the past if this QDeadlineTimer has expired.

Calls C++ function: qint64 QDeadlineTimer::deadlineNSecs() const.

C++ documentation:

Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in nanoseconds relative to the reference clock, the same as QElapsedTimer::msecsSinceReference(). The value will be in the past if this QDeadlineTimer has expired.

If this QDeadlineTimer never expires, this function returns std::numeric_limits<qint64>::max().

This function can be used to calculate the amount of time a timer is overdue, by subtracting QDeadlineTimer::current(), as in the following example:

qint64 realTimeLeft = deadline.deadlineNSecs(); if (realTimeLeft != std::numeric_limits<qint64>::max()) realTimeLeft -= QDeadlineTimer::current().deadlineNSecs();

Note: Timers that were created as expired have an indetermine time point in the past as their deadline, so the above calculation may not work.

See also remainingTime() and deadlineNSecs().

source

pub unsafe fn has_expired(&self) -> bool

Returns true if this QDeadlineTimer object has expired, false if there remains time left. For objects that have expired, remainingTime() will return zero and deadline() will return a time point in the past.

Calls C++ function: bool QDeadlineTimer::hasExpired() const.

C++ documentation:

Returns true if this QDeadlineTimer object has expired, false if there remains time left. For objects that have expired, remainingTime() will return zero and deadline() will return a time point in the past.

QDeadlineTimer objects created with the ForeverConstant never expire and this function always returns false for them.

See also isForever() and remainingTime().

source

pub unsafe fn is_forever(&self) -> bool

Returns true if this QDeadlineTimer object never expires, false otherwise. For timers that never expire, remainingTime() always returns -1 and deadline() returns the maximum value.

Calls C++ function: bool QDeadlineTimer::isForever() const.

C++ documentation:

Returns true if this QDeadlineTimer object never expires, false otherwise. For timers that never expire, remainingTime() always returns -1 and deadline() returns the maximum value.

See also ForeverConstant, hasExpired(), and remainingTime().

source

pub unsafe fn from_timer_type(type_: TimerType) -> CppBox<QDeadlineTimer>

Constructs an expired QDeadlineTimer object. For this object, remainingTime() will return 0.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(Qt::TimerType type_ = …).

C++ documentation:

Constructs an expired QDeadlineTimer object. For this object, remainingTime() will return 0.

The timer type timerType may be ignored, since the timer is already expired. Similarly, for optimization purposes, this function will not attempt to obtain the current time and will use a value known to be in the past. Therefore, deadline() may return an unexpected value and this object cannot be used in calculation of how long it is overdue. If that functionality is required, use QDeadlineTimer::current().

See also hasExpired(), remainingTime(), Qt::TimerType, and current().

source

pub unsafe fn from_forever_constant_timer_type( arg1: ForeverConstant, type_: TimerType ) -> CppBox<QDeadlineTimer>

QDeadlineTimer objects created with parameter forever never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(QDeadlineTimer::ForeverConstant arg1, Qt::TimerType type_ = …).

C++ documentation:

QDeadlineTimer objects created with parameter forever never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true.

The timer type timerType may be ignored, since the timer is already expired.

See also ForeverConstant, hasExpired(), isForever(), remainingTime(), and timerType().

source

pub unsafe fn from_i64_timer_type( msecs: i64, type_: TimerType ) -> CppBox<QDeadlineTimer>

Constructs a QDeadlineTimer object with an expiry time of msecs msecs from the moment of the creation of this object, if msecs is positive. If msecs is zero, this QDeadlineTimer will be marked as expired, causing remainingTime() to return zero and deadline() to return an indeterminate time point in the past. If msecs is -1, the timer will be set it to never expire, causing remainingTime() to return -1 and deadline() to return the maximum value.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type = …).

C++ documentation:

Constructs a QDeadlineTimer object with an expiry time of msecs msecs from the moment of the creation of this object, if msecs is positive. If msecs is zero, this QDeadlineTimer will be marked as expired, causing remainingTime() to return zero and deadline() to return an indeterminate time point in the past. If msecs is -1, the timer will be set it to never expire, causing remainingTime() to return -1 and deadline() to return the maximum value.

The QDeadlineTimer object will be constructed with the specified timer type.

For optimization purposes, if msecs is zero, this function may skip obtaining the current time and may instead use a value known to be in the past. If that happens, deadline() may return an unexpected value and this object cannot be used in calculation of how long it is overdue. If that functionality is required, use QDeadlineTimer::current() and add time to it.

See also hasExpired(), isForever(), remainingTime(), and setRemainingTime().

source

pub unsafe fn new() -> CppBox<QDeadlineTimer>

The QDeadlineTimer class marks a deadline in the future.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer().

C++ documentation:

The QDeadlineTimer class marks a deadline in the future.

The QDeadlineTimer class is usually used to calculate future deadlines and verify whether the deadline has expired. QDeadlineTimer can also be used for deadlines without expiration ("forever"). It forms a counterpart to QElapsedTimer, which calculates how much time has elapsed since QElapsedTimer::start() was called.

QDeadlineTimer provides a more convenient API compared to QElapsedTimer::hasExpired().

The typical use-case for the class is to create a QDeadlineTimer before the operation in question is started, and then use remainingTime() or hasExpired() to determine whether to continue trying the operation. QDeadlineTimer objects can be passed to functions being called to execute this operation so they know how long to still operate.

void executeOperation(int msecs) { QDeadlineTimer deadline(msecs); do { if (readFromDevice(deadline.remainingTime()) break; waitForReadyRead(deadline); } while (!deadline.hasExpired()); }

Many QDeadlineTimer functions deal with time out values, which all are measured in milliseconds. There are two special values, the same as many other Qt functions named waitFor or similar:

  • 0: no time left, expired
  • -1: infinite time left, timer never expires
source

pub unsafe fn from_forever_constant( arg1: ForeverConstant ) -> CppBox<QDeadlineTimer>

QDeadlineTimer objects created with parameter forever never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(QDeadlineTimer::ForeverConstant arg1).

C++ documentation:

QDeadlineTimer objects created with parameter forever never expire. For such objects, remainingTime() will return -1, deadline() will return the maximum value, and isForever() will return true.

The timer type timerType may be ignored, since the timer is already expired.

See also ForeverConstant, hasExpired(), isForever(), remainingTime(), and timerType().

source

pub unsafe fn from_i64(msecs: i64) -> CppBox<QDeadlineTimer>

Constructs a QDeadlineTimer object with an expiry time of msecs msecs from the moment of the creation of this object, if msecs is positive. If msecs is zero, this QDeadlineTimer will be marked as expired, causing remainingTime() to return zero and deadline() to return an indeterminate time point in the past. If msecs is -1, the timer will be set it to never expire, causing remainingTime() to return -1 and deadline() to return the maximum value.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(qint64 msecs).

C++ documentation:

Constructs a QDeadlineTimer object with an expiry time of msecs msecs from the moment of the creation of this object, if msecs is positive. If msecs is zero, this QDeadlineTimer will be marked as expired, causing remainingTime() to return zero and deadline() to return an indeterminate time point in the past. If msecs is -1, the timer will be set it to never expire, causing remainingTime() to return -1 and deadline() to return the maximum value.

The QDeadlineTimer object will be constructed with the specified timer type.

For optimization purposes, if msecs is zero, this function may skip obtaining the current time and may instead use a value known to be in the past. If that happens, deadline() may return an unexpected value and this object cannot be used in calculation of how long it is overdue. If that functionality is required, use QDeadlineTimer::current() and add time to it.

See also hasExpired(), isForever(), remainingTime(), and setRemainingTime().

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QDeadlineTimer>> ) -> CppBox<QDeadlineTimer>

The QDeadlineTimer class marks a deadline in the future.

Calls C++ function: [constructor] void QDeadlineTimer::QDeadlineTimer(const QDeadlineTimer& other).

C++ documentation:

The QDeadlineTimer class marks a deadline in the future.

The QDeadlineTimer class is usually used to calculate future deadlines and verify whether the deadline has expired. QDeadlineTimer can also be used for deadlines without expiration ("forever"). It forms a counterpart to QElapsedTimer, which calculates how much time has elapsed since QElapsedTimer::start() was called.

QDeadlineTimer provides a more convenient API compared to QElapsedTimer::hasExpired().

The typical use-case for the class is to create a QDeadlineTimer before the operation in question is started, and then use remainingTime() or hasExpired() to determine whether to continue trying the operation. QDeadlineTimer objects can be passed to functions being called to execute this operation so they know how long to still operate.

void executeOperation(int msecs) { QDeadlineTimer deadline(msecs); do { if (readFromDevice(deadline.remainingTime()) break; waitForReadyRead(deadline); } while (!deadline.hasExpired()); }

Many QDeadlineTimer functions deal with time out values, which all are measured in milliseconds. There are two special values, the same as many other Qt functions named waitFor or similar:

  • 0: no time left, expired
  • -1: infinite time left, timer never expires
source

pub unsafe fn q_data(&self) -> CppBox<QPairOfI64Uint>

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Calls C++ function: QPair<qint64, unsigned int> QDeadlineTimer::_q_data() const.

source

pub unsafe fn remaining_time(&self) -> i64

Returns the remaining time in this QDeadlineTimer object in milliseconds. If the timer has already expired, this function will return zero and it is not possible to obtain the amount of time overdue with this function (to do that, see deadline()). If the timer was set to never expire, this function returns -1.

Calls C++ function: qint64 QDeadlineTimer::remainingTime() const.

C++ documentation:

Returns the remaining time in this QDeadlineTimer object in milliseconds. If the timer has already expired, this function will return zero and it is not possible to obtain the amount of time overdue with this function (to do that, see deadline()). If the timer was set to never expire, this function returns -1.

This function is suitable for use in Qt APIs that take a millisecond timeout, such as the many QIODevice waitFor functions or the timed lock functions in QMutex, QWaitCondition, QSemaphore, or QReadWriteLock. For example:

mutex.tryLock(deadline.remainingTime());

See also setRemainingTime(), remainingTimeNSecs(), isForever(), and hasExpired().

source

pub unsafe fn remaining_time_n_secs(&self) -> i64

Returns the remaining time in this QDeadlineTimer object in nanoseconds. If the timer has already expired, this function will return zero and it is not possible to obtain the amount of time overdue with this function. If the timer was set to never expire, this function returns -1.

Calls C++ function: qint64 QDeadlineTimer::remainingTimeNSecs() const.

C++ documentation:

Returns the remaining time in this QDeadlineTimer object in nanoseconds. If the timer has already expired, this function will return zero and it is not possible to obtain the amount of time overdue with this function. If the timer was set to never expire, this function returns -1.

See also remainingTime(), isForever(), and hasExpired().

source

pub unsafe fn set_deadline_2a(&self, msecs: i64, timer_type: TimerType)

Sets the deadline for this QDeadlineTimer object to be the msecs absolute time point, counted in milliseconds since the reference clock (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType = …).

C++ documentation:

Sets the deadline for this QDeadlineTimer object to be the msecs absolute time point, counted in milliseconds since the reference clock (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

If msecs is std::numeric_limits<qint64>::max(), this QDeadlineTimer will be set to never expire.

See also setPreciseDeadline(), deadline(), deadlineNSecs(), and setRemainingTime().

source

pub unsafe fn set_deadline_1a(&self, msecs: i64)

Sets the deadline for this QDeadlineTimer object to be the msecs absolute time point, counted in milliseconds since the reference clock (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setDeadline(qint64 msecs).

C++ documentation:

Sets the deadline for this QDeadlineTimer object to be the msecs absolute time point, counted in milliseconds since the reference clock (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

If msecs is std::numeric_limits<qint64>::max(), this QDeadlineTimer will be set to never expire.

See also setPreciseDeadline(), deadline(), deadlineNSecs(), and setRemainingTime().

source

pub unsafe fn set_precise_deadline_3a( &self, secs: i64, nsecs: i64, type_: TimerType )

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs = …, Qt::TimerType type = …).

C++ documentation:

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

If secs or nsecs is std::numeric_limits<qint64>::max(), this QDeadlineTimer will be set to never expire. If nsecs is more than 1 billion nanoseconds (1 second), then secs will be adjusted accordingly.

See also setDeadline(), deadline(), deadlineNSecs(), and setRemainingTime().

source

pub unsafe fn set_precise_deadline_2a(&self, secs: i64, nsecs: i64)

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs = …).

C++ documentation:

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

If secs or nsecs is std::numeric_limits<qint64>::max(), this QDeadlineTimer will be set to never expire. If nsecs is more than 1 billion nanoseconds (1 second), then secs will be adjusted accordingly.

See also setDeadline(), deadline(), deadlineNSecs(), and setRemainingTime().

source

pub unsafe fn set_precise_deadline_1a(&self, secs: i64)

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseDeadline(qint64 secs).

C++ documentation:

Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the reference clock epoch (the same as QElapsedTimer::msecsSinceReference()), and the timer type to timerType. If the value is in the past, this QDeadlineTimer will be marked as expired.

If secs or nsecs is std::numeric_limits<qint64>::max(), this QDeadlineTimer will be set to never expire. If nsecs is more than 1 billion nanoseconds (1 second), then secs will be adjusted accordingly.

See also setDeadline(), deadline(), deadlineNSecs(), and setRemainingTime().

source

pub unsafe fn set_precise_remaining_time_3a( &self, secs: i64, nsecs: i64, type_: TimerType )

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs = …, Qt::TimerType type = …).

C++ documentation:

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

The timer type for this QDeadlineTimer object will be set to the specified timerType.

See also setRemainingTime(), hasExpired(), isForever(), and remainingTime().

source

pub unsafe fn set_precise_remaining_time_2a(&self, secs: i64, nsecs: i64)

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs = …).

C++ documentation:

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

The timer type for this QDeadlineTimer object will be set to the specified timerType.

See also setRemainingTime(), hasExpired(), isForever(), and remainingTime().

source

pub unsafe fn set_precise_remaining_time_1a(&self, secs: i64)

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

Calls C++ function: void QDeadlineTimer::setPreciseRemainingTime(qint64 secs).

C++ documentation:

Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from now, if secs has a positive value. If secs is -1, this QDeadlineTimer will be set it to never expire. If both parameters are zero, this QDeadlineTimer will be marked as expired.

The timer type for this QDeadlineTimer object will be set to the specified timerType.

See also setRemainingTime(), hasExpired(), isForever(), and remainingTime().

source

pub unsafe fn set_remaining_time_2a(&self, msecs: i64, type_: TimerType)

Sets the remaining time for this QDeadlineTimer object to msecs milliseconds from now, if msecs has a positive value. If msecs is zero, this QDeadlineTimer object will be marked as expired, whereas a value of -1 will set it to never expire.

Calls C++ function: void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType type = …).

C++ documentation:

Sets the remaining time for this QDeadlineTimer object to msecs milliseconds from now, if msecs has a positive value. If msecs is zero, this QDeadlineTimer object will be marked as expired, whereas a value of -1 will set it to never expire.

The timer type for this QDeadlineTimer object will be set to the specified timerType.

See also setPreciseRemainingTime(), hasExpired(), isForever(), and remainingTime().

source

pub unsafe fn set_remaining_time_1a(&self, msecs: i64)

Sets the remaining time for this QDeadlineTimer object to msecs milliseconds from now, if msecs has a positive value. If msecs is zero, this QDeadlineTimer object will be marked as expired, whereas a value of -1 will set it to never expire.

Calls C++ function: void QDeadlineTimer::setRemainingTime(qint64 msecs).

C++ documentation:

Sets the remaining time for this QDeadlineTimer object to msecs milliseconds from now, if msecs has a positive value. If msecs is zero, this QDeadlineTimer object will be marked as expired, whereas a value of -1 will set it to never expire.

The timer type for this QDeadlineTimer object will be set to the specified timerType.

See also setPreciseRemainingTime(), hasExpired(), isForever(), and remainingTime().

source

pub unsafe fn set_timer_type(&self, type_: TimerType)

Changes the timer type for this object to timerType.

Calls C++ function: void QDeadlineTimer::setTimerType(Qt::TimerType type).

C++ documentation:

Changes the timer type for this object to timerType.

The behavior for each possible value of timerType is operating-system dependent. Qt::PreciseTimer will use the most precise timer that Qt can find, with resolution of 1 millisecond or better, whereas QDeadlineTimer will try to use a more coarse timer for Qt::CoarseTimer and Qt::VeryCoarseTimer.

See also timerType() and Qt::TimerType.

source

pub unsafe fn sub_assign(&self, msecs: i64) -> Ref<QDeadlineTimer>

Shortens this QDeadlineTimer object by msecs milliseconds and returns itself. If this object is set to never expire, this function does nothing.

Calls C++ function: QDeadlineTimer& QDeadlineTimer::operator-=(qint64 msecs).

C++ documentation:

Shortens this QDeadlineTimer object by msecs milliseconds and returns itself. If this object is set to never expire, this function does nothing.

To subtract times of precision greater than 1 millisecond, use addNSecs().

source

pub unsafe fn swap(&self, other: impl CastInto<Ref<QDeadlineTimer>>)

Swaps this deadline timer with the other deadline timer.

Calls C++ function: void QDeadlineTimer::swap(QDeadlineTimer& other).

C++ documentation:

Swaps this deadline timer with the other deadline timer.

source

pub unsafe fn timer_type(&self) -> TimerType

Returns the timer type is active for this object.

Calls C++ function: Qt::TimerType QDeadlineTimer::timerType() const.

C++ documentation:

Returns the timer type is active for this object.

See also setTimerType().

Trait Implementations§

source§

impl CppDeletable for QDeadlineTimer

source§

unsafe fn delete(&self)

The QDeadlineTimer class marks a deadline in the future.

Calls C++ function: [destructor] void QDeadlineTimer::~QDeadlineTimer().

C++ documentation:

The QDeadlineTimer class marks a deadline in the future.

The QDeadlineTimer class is usually used to calculate future deadlines and verify whether the deadline has expired. QDeadlineTimer can also be used for deadlines without expiration ("forever"). It forms a counterpart to QElapsedTimer, which calculates how much time has elapsed since QElapsedTimer::start() was called.

QDeadlineTimer provides a more convenient API compared to QElapsedTimer::hasExpired().

The typical use-case for the class is to create a QDeadlineTimer before the operation in question is started, and then use remainingTime() or hasExpired() to determine whether to continue trying the operation. QDeadlineTimer objects can be passed to functions being called to execute this operation so they know how long to still operate.

void executeOperation(int msecs) { QDeadlineTimer deadline(msecs); do { if (readFromDevice(deadline.remainingTime()) break; waitForReadyRead(deadline); } while (!deadline.hasExpired()); }

Many QDeadlineTimer functions deal with time out values, which all are measured in milliseconds. There are two special values, the same as many other Qt functions named waitFor or similar:

  • 0: no time left, expired
  • -1: infinite time left, timer never expires

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.