[][src]Struct qt_core::QDeadlineTimer

#[repr(C)]
pub struct QDeadlineTimer { /* fields omitted */ }

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

Methods

impl QDeadlineTimer[src]

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

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.

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QDeadlineTimer>>
) -> MutRef<QDeadlineTimer>
[src]

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

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

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.

pub unsafe fn current_0a() -> CppBox<QDeadlineTimer>[src]

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.

pub unsafe fn deadline(&self) -> i64[src]

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().

pub unsafe fn deadline_n_secs(&self) -> i64[src]

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().

pub unsafe fn has_expired(&self) -> bool[src]

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().

pub unsafe fn is_forever(&self) -> bool[src]

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().

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

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().

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

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().

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

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().

pub unsafe fn new() -> CppBox<QDeadlineTimer>[src]

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

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

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().

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

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().

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

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

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

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

This item is available if any(cpp_lib_version="5.12.2", cpp_lib_version="5.13.0").

pub unsafe fn remaining_time(&self) -> i64[src]

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().

pub unsafe fn remaining_time_n_secs(&self) -> i64[src]

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().

pub unsafe fn set_deadline_2a(&mut self, msecs: i64, timer_type: TimerType)[src]

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().

pub unsafe fn set_deadline_1a(&mut self, msecs: i64)[src]

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().

pub unsafe fn set_precise_deadline_3a(
    &mut self,
    secs: i64,
    nsecs: i64,
    type_: TimerType
)
[src]

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().

pub unsafe fn set_precise_deadline_2a(&mut self, secs: i64, nsecs: i64)[src]

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().

pub unsafe fn set_precise_deadline_1a(&mut self, secs: i64)[src]

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().

pub unsafe fn set_precise_remaining_time_3a(
    &mut self,
    secs: i64,
    nsecs: i64,
    type_: TimerType
)
[src]

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().

pub unsafe fn set_precise_remaining_time_2a(&mut self, secs: i64, nsecs: i64)[src]

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().

pub unsafe fn set_precise_remaining_time_1a(&mut self, secs: i64)[src]

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().

pub unsafe fn set_remaining_time_2a(&mut self, msecs: i64, type_: TimerType)[src]

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().

pub unsafe fn set_remaining_time_1a(&mut self, msecs: i64)[src]

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().

pub unsafe fn set_timer_type(&mut self, type_: TimerType)[src]

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.

pub unsafe fn swap(&mut self, other: impl CastInto<MutRef<QDeadlineTimer>>)[src]

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.

pub unsafe fn timer_type(&self) -> TimerType[src]

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

impl AddAssign<i64> for QDeadlineTimer[src]

fn add_assign(&mut self, msecs: i64)[src]

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().

impl SubAssign<i64> for QDeadlineTimer[src]

fn sub_assign(&mut self, msecs: i64)[src]

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().

impl CppDeletable for QDeadlineTimer[src]

unsafe fn delete(&mut self)[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]