#[repr(C)]pub struct QTime { /* private fields */ }
Expand description
The QTime class provides clock time functions.
C++ class: QTime
.
The QTime class provides clock time functions.
A QTime object contains a clock time, i.e. the number of hours, minutes, seconds, and milliseconds since midnight. It can read the current time from the system clock and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.
QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight-saving time (DST).
A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function currentTime(), which creates a QTime object that contains the system's local time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
The hour(), minute(), second(), and msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the toString() function.
QTime provides a full set of operators to compare two QTime objects. QTime A is considered smaller than QTime B if A is earlier than B.
The addSecs() and addMSecs() functions provide the time a given number of seconds or milliseconds later than a given time. Correspondingly, the number of seconds or milliseconds between two times can be found using secsTo() or msecsTo().
QTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions.
Implementations§
source§impl QTime
impl QTime
sourcepub unsafe fn add_m_secs(&self, ms: c_int) -> CppBox<QTime>
pub unsafe fn add_m_secs(&self, ms: c_int) -> CppBox<QTime>
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earlier if ms is negative).
Calls C++ function: QTime QTime::addMSecs(int ms) const
.
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earlier if ms is negative).
Note that the time will wrap if it passes midnight. See addSecs() for an example.
Returns a null time if this time is invalid.
See also addSecs(), msecsTo(), and QDateTime::addMSecs().
sourcepub unsafe fn add_secs(&self, secs: c_int) -> CppBox<QTime>
pub unsafe fn add_secs(&self, secs: c_int) -> CppBox<QTime>
Returns a QTime object containing a time s seconds later than the time of this object (or earlier if s is negative).
Calls C++ function: QTime QTime::addSecs(int secs) const
.
Returns a QTime object containing a time s seconds later than the time of this object (or earlier if s is negative).
Note that the time will wrap if it passes midnight.
Returns a null time if this time is invalid.
Example:
QTime n(14, 0, 0); // n == 14:00:00 QTime t; t = n.addSecs(70); // t == 14:01:10 t = n.addSecs(-70); // t == 13:58:50 t = n.addSecs(10 60 60 + 5); // t == 00:00:05 t = n.addSecs(-15 60 60); // t == 23:00:00
See also addMSecs(), secsTo(), and QDateTime::addSecs().
sourcepub unsafe fn copy_from(&self, other: impl CastInto<Ref<QTime>>) -> Ref<QTime>
pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QTime>>) -> Ref<QTime>
The QTime class provides clock time functions.
Calls C++ function: QTime& QTime::operator=(const QTime& other)
.
The QTime class provides clock time functions.
A QTime object contains a clock time, i.e. the number of hours, minutes, seconds, and milliseconds since midnight. It can read the current time from the system clock and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.
QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight-saving time (DST).
A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function currentTime(), which creates a QTime object that contains the system's local time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
The hour(), minute(), second(), and msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the toString() function.
QTime provides a full set of operators to compare two QTime objects. QTime A is considered smaller than QTime B if A is earlier than B.
The addSecs() and addMSecs() functions provide the time a given number of seconds or milliseconds later than a given time. Correspondingly, the number of seconds or milliseconds between two times can be found using secsTo() or msecsTo().
QTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions.
sourcepub unsafe fn current_time() -> CppBox<QTime>
pub unsafe fn current_time() -> CppBox<QTime>
Returns the current time as reported by the system clock.
Calls C++ function: static QTime QTime::currentTime()
.
Returns the current time as reported by the system clock.
Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
sourcepub unsafe fn elapsed(&self) -> c_int
pub unsafe fn elapsed(&self) -> c_int
Returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
Calls C++ function: int QTime::elapsed() const
.
Returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
Note that the counter wraps to zero 24 hours after the last call to start() or restart.
Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
Warning: If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight-saving time is turned on or off.
sourcepub unsafe fn from_m_secs_since_start_of_day(msecs: c_int) -> CppBox<QTime>
pub unsafe fn from_m_secs_since_start_of_day(msecs: c_int) -> CppBox<QTime>
Returns a new QTime instance with the time set to the number of msecs since the start of the day, i.e. since 00:00:00.
Calls C++ function: static QTime QTime::fromMSecsSinceStartOfDay(int msecs)
.
Returns a new QTime instance with the time set to the number of msecs since the start of the day, i.e. since 00:00:00.
If msecs falls outside the valid range an invalid QTime will be returned.
See also msecsSinceStartOfDay().
sourcepub unsafe fn from_string_q_string_date_format(
s: impl CastInto<Ref<QString>>,
f: DateFormat
) -> CppBox<QTime>
pub unsafe fn from_string_q_string_date_format( s: impl CastInto<Ref<QString>>, f: DateFormat ) -> CppBox<QTime>
Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.
Calls C++ function: static QTime QTime::fromString(const QString& s, Qt::DateFormat f = …)
.
Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.
Note that fromString() uses a "C" locale encoded string to convert milliseconds to a float value. If the default locale is not "C", this may result in two conversion attempts (if the conversion fails for the default locale). This should be considered an implementation detail.
See also toString() and QLocale::toTime().
sourcepub unsafe fn from_string_2_q_string(
s: impl CastInto<Ref<QString>>,
format: impl CastInto<Ref<QString>>
) -> CppBox<QTime>
pub unsafe fn from_string_2_q_string( s: impl CastInto<Ref<QString>>, format: impl CastInto<Ref<QString>> ) -> CppBox<QTime>
Returns the QTime represented by the string, using the format given, or an invalid time if the string cannot be parsed.
Calls C++ function: static QTime QTime::fromString(const QString& s, const QString& format)
.
Returns the QTime represented by the string, using the format given, or an invalid time if the string cannot be parsed.
These expressions may be used for the format:
Expression | Output |
---|---|
h | the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) |
hh | the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) |
m | the minute without a leading zero (0 to 59) |
mm | the minute with a leading zero (00 to 59) |
s | the whole second, without any leading zero (0 to 59) |
ss | the whole second, with a leading zero where applicable (00 to 59) |
z | the fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus "s.z " reports the seconds to full available (millisecond) precision without trailing zeroes. |
zzz | the fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999). |
AP | interpret as an AM/PM time. AP must be either "AM" or "PM". |
ap | Interpret as an AM/PM time. ap must be either "am" or "pm". |
All other input characters will be treated as text. Any sequence of characters that are enclosed in single quotes will also be treated as text and not be used as an expression.
QTime time = QTime::fromString(“1mm12car00”, “m’mm’hcarss”); // time is 12:01.00
If the format is not satisfied, an invalid QTime is returned. Expressions that do not expect leading zeroes to be given (h, m, s and z) are greedy. This means that they will use two digits even if this puts them outside the range of accepted values and leaves too few digits for other sections. For example, the following string could have meant 00:07:10, but the m will grab two digits, resulting in an invalid time:
QTime time = QTime::fromString(“00:710”, “hh:ms”); // invalid
Any field that is not represented in the format will be set to zero. For example:
QTime time = QTime::fromString(“1.30”, “m.s”); // time is 00:01:30.000
See also toString(), QDateTime::fromString(), QDate::fromString(), and QLocale::toTime().
sourcepub unsafe fn from_string_q_string(
s: impl CastInto<Ref<QString>>
) -> CppBox<QTime>
pub unsafe fn from_string_q_string( s: impl CastInto<Ref<QString>> ) -> CppBox<QTime>
Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.
Calls C++ function: static QTime QTime::fromString(const QString& s)
.
Returns the time represented in the string as a QTime using the format given, or an invalid time if this is not possible.
Note that fromString() uses a "C" locale encoded string to convert milliseconds to a float value. If the default locale is not "C", this may result in two conversion attempts (if the conversion fails for the default locale). This should be considered an implementation detail.
See also toString() and QLocale::toTime().
sourcepub unsafe fn hour(&self) -> c_int
pub unsafe fn hour(&self) -> c_int
Returns the hour part (0 to 23) of the time.
Calls C++ function: int QTime::hour() const
.
sourcepub unsafe fn is_null(&self) -> bool
pub unsafe fn is_null(&self) -> bool
Returns true
if the time is null (i.e., the QTime object was constructed using the default constructor); otherwise returns false. A null time is also an invalid time.
Calls C++ function: bool QTime::isNull() const
.
sourcepub unsafe fn is_valid_0a(&self) -> bool
pub unsafe fn is_valid_0a(&self) -> bool
Returns true
if the time is valid; otherwise returns false
. For example, the time 23:30:55.746 is valid, but 24:12:30 is invalid.
Calls C++ function: bool QTime::isValid() const
.
Returns true
if the time is valid; otherwise returns false
. For example, the time 23:30:55.746 is valid, but 24:12:30 is invalid.
See also isNull().
sourcepub unsafe fn is_valid_4a(h: c_int, m: c_int, s: c_int, ms: c_int) -> bool
pub unsafe fn is_valid_4a(h: c_int, m: c_int, s: c_int, ms: c_int) -> bool
This is an overloaded function.
Calls C++ function: static bool QTime::isValid(int h, int m, int s, int ms = …)
.
This is an overloaded function.
Returns true
if the specified time is valid; otherwise returns false.
The time is valid if h is in the range 0 to 23, m and s are in the range 0 to 59, and ms is in the range 0 to 999.
Example:
QTime::isValid(21, 10, 30); // returns true QTime::isValid(22, 5, 62); // returns false
sourcepub unsafe fn is_valid_3a(h: c_int, m: c_int, s: c_int) -> bool
pub unsafe fn is_valid_3a(h: c_int, m: c_int, s: c_int) -> bool
This is an overloaded function.
Calls C++ function: static bool QTime::isValid(int h, int m, int s)
.
This is an overloaded function.
Returns true
if the specified time is valid; otherwise returns false.
The time is valid if h is in the range 0 to 23, m and s are in the range 0 to 59, and ms is in the range 0 to 999.
Example:
QTime::isValid(21, 10, 30); // returns true QTime::isValid(22, 5, 62); // returns false
sourcepub unsafe fn minute(&self) -> c_int
pub unsafe fn minute(&self) -> c_int
Returns the minute part (0 to 59) of the time.
Calls C++ function: int QTime::minute() const
.
sourcepub unsafe fn msec(&self) -> c_int
pub unsafe fn msec(&self) -> c_int
Returns the millisecond part (0 to 999) of the time.
Calls C++ function: int QTime::msec() const
.
sourcepub unsafe fn msecs_since_start_of_day(&self) -> c_int
pub unsafe fn msecs_since_start_of_day(&self) -> c_int
Returns the number of msecs since the start of the day, i.e. since 00:00:00.
Calls C++ function: int QTime::msecsSinceStartOfDay() const
.
Returns the number of msecs since the start of the day, i.e. since 00:00:00.
See also fromMSecsSinceStartOfDay().
sourcepub unsafe fn msecs_to(&self, arg1: impl CastInto<Ref<QTime>>) -> c_int
pub unsafe fn msecs_to(&self, arg1: impl CastInto<Ref<QTime>>) -> c_int
Returns the number of milliseconds from this time to t. If t is earlier than this time, the number of milliseconds returned is negative.
Calls C++ function: int QTime::msecsTo(const QTime& arg1) const
.
Returns the number of milliseconds from this time to t. If t is earlier than this time, the number of milliseconds returned is negative.
Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400000 and 86400000 ms.
Returns 0 if either time is invalid.
See also secsTo(), addMSecs(), and QDateTime::msecsTo().
sourcepub unsafe fn new_0a() -> CppBox<QTime>
pub unsafe fn new_0a() -> CppBox<QTime>
sourcepub unsafe fn new_4a(h: c_int, m: c_int, s: c_int, ms: c_int) -> CppBox<QTime>
pub unsafe fn new_4a(h: c_int, m: c_int, s: c_int, ms: c_int) -> CppBox<QTime>
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
Calls C++ function: [constructor] void QTime::QTime(int h, int m, int s = …, int ms = …)
.
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999.
See also isValid().
sourcepub unsafe fn new_3a(h: c_int, m: c_int, s: c_int) -> CppBox<QTime>
pub unsafe fn new_3a(h: c_int, m: c_int, s: c_int) -> CppBox<QTime>
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
Calls C++ function: [constructor] void QTime::QTime(int h, int m, int s = …)
.
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999.
See also isValid().
sourcepub unsafe fn new_2a(h: c_int, m: c_int) -> CppBox<QTime>
pub unsafe fn new_2a(h: c_int, m: c_int) -> CppBox<QTime>
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
Calls C++ function: [constructor] void QTime::QTime(int h, int m)
.
Constructs a time with hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999.
See also isValid().
sourcepub unsafe fn new_copy(other: impl CastInto<Ref<QTime>>) -> CppBox<QTime>
pub unsafe fn new_copy(other: impl CastInto<Ref<QTime>>) -> CppBox<QTime>
The QTime class provides clock time functions.
Calls C++ function: [constructor] void QTime::QTime(const QTime& other)
.
The QTime class provides clock time functions.
A QTime object contains a clock time, i.e. the number of hours, minutes, seconds, and milliseconds since midnight. It can read the current time from the system clock and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.
QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight-saving time (DST).
A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function currentTime(), which creates a QTime object that contains the system's local time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
The hour(), minute(), second(), and msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the toString() function.
QTime provides a full set of operators to compare two QTime objects. QTime A is considered smaller than QTime B if A is earlier than B.
The addSecs() and addMSecs() functions provide the time a given number of seconds or milliseconds later than a given time. Correspondingly, the number of seconds or milliseconds between two times can be found using secsTo() or msecsTo().
QTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions.
sourcepub unsafe fn restart(&self) -> c_int
pub unsafe fn restart(&self) -> c_int
Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
Calls C++ function: int QTime::restart()
.
Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time start() or restart() was called.
This function is guaranteed to be atomic and is thus very handy for repeated measurements. Call start() to start the first measurement, and restart() for each later measurement.
Note that the counter wraps to zero 24 hours after the last call to start() or restart().
Warning: If the system's clock setting has been changed since the last time start() or restart() was called, the result is undefined. This can happen when daylight-saving time is turned on or off.
See also start(), elapsed(), and currentTime().
sourcepub unsafe fn second(&self) -> c_int
pub unsafe fn second(&self) -> c_int
Returns the second part (0 to 59) of the time.
Calls C++ function: int QTime::second() const
.
sourcepub unsafe fn secs_to(&self, arg1: impl CastInto<Ref<QTime>>) -> c_int
pub unsafe fn secs_to(&self, arg1: impl CastInto<Ref<QTime>>) -> c_int
Returns the number of seconds from this time to t. If t is earlier than this time, the number of seconds returned is negative.
Calls C++ function: int QTime::secsTo(const QTime& arg1) const
.
Returns the number of seconds from this time to t. If t is earlier than this time, the number of seconds returned is negative.
Because QTime measures time within a day and there are 86400 seconds in a day, the result is always between -86400 and 86400.
secsTo() does not take into account any milliseconds.
Returns 0 if either time is invalid.
See also addSecs() and QDateTime::secsTo().
sourcepub unsafe fn set_h_m_s_4a(
&self,
h: c_int,
m: c_int,
s: c_int,
ms: c_int
) -> bool
pub unsafe fn set_h_m_s_4a( &self, h: c_int, m: c_int, s: c_int, ms: c_int ) -> bool
Sets the time to hour h, minute m, seconds s and milliseconds ms.
Calls C++ function: bool QTime::setHMS(int h, int m, int s, int ms = …)
.
Sets the time to hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999. Returns true
if the set time is valid; otherwise returns false
.
See also isValid().
sourcepub unsafe fn set_h_m_s_3a(&self, h: c_int, m: c_int, s: c_int) -> bool
pub unsafe fn set_h_m_s_3a(&self, h: c_int, m: c_int, s: c_int) -> bool
Sets the time to hour h, minute m, seconds s and milliseconds ms.
Calls C++ function: bool QTime::setHMS(int h, int m, int s)
.
Sets the time to hour h, minute m, seconds s and milliseconds ms.
h must be in the range 0 to 23, m and s must be in the range 0 to 59, and ms must be in the range 0 to 999. Returns true
if the set time is valid; otherwise returns false
.
See also isValid().
sourcepub unsafe fn start(&self)
pub unsafe fn start(&self)
Sets this time to the current time. This is practical for timing:
Calls C++ function: void QTime::start()
.
Sets this time to the current time. This is practical for timing:
QTime t; t.start(); some_lengthy_task(); qDebug("Time elapsed: %d ms", t.elapsed());
See also restart(), elapsed(), and currentTime().
sourcepub unsafe fn to_string_date_format(&self, f: DateFormat) -> CppBox<QString>
pub unsafe fn to_string_date_format(&self, f: DateFormat) -> CppBox<QString>
This is an overloaded function.
Calls C++ function: QString QTime::toString(Qt::DateFormat f = …) const
.
This is an overloaded function.
Returns the time as a string. The format parameter determines the format of the string.
If format is Qt::TextDate, the string format is HH:mm:ss; e.g. 1 second before midnight would be "23:59:59".
If format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates, represented by HH:mm:ss. To include milliseconds in the ISO 8601 date, use the format Qt::ISODateWithMs, which corresponds to HH:mm:ss.zzz.
If the format is Qt::SystemLocaleShortDate or Qt::SystemLocaleLongDate, the string format depends on the locale settings of the system. Identical to calling QLocale::system().toString(time, QLocale::ShortFormat) or QLocale::system().toString(time, QLocale::LongFormat).
If the format is Qt::DefaultLocaleShortDate or Qt::DefaultLocaleLongDate, the string format depends on the default application locale. This is the locale set with QLocale::setDefault(), or the system locale if no default locale has been set. Identical to calling
QLocale().toString(time, QLocale::ShortFormat) or QLocale().toString(time, QLocale::LongFormat).
If the format is Qt::RFC2822Date, the string is formatted in an RFC 2822 compatible way. An example of this formatting is "23:59:20".
If the time is invalid, an empty string will be returned.
See also fromString(), QDate::toString(), QDateTime::toString(), and QLocale::toString().
sourcepub unsafe fn to_string_q_string(
&self,
format: impl CastInto<Ref<QString>>
) -> CppBox<QString>
pub unsafe fn to_string_q_string( &self, format: impl CastInto<Ref<QString>> ) -> CppBox<QString>
Returns the time as a string. The format parameter determines the format of the result string.
Calls C++ function: QString QTime::toString(const QString& format) const
.
Returns the time as a string. The format parameter determines the format of the result string.
These expressions may be used:
Expression | Output |
---|---|
h | the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) |
hh | the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) |
H | the hour without a leading zero (0 to 23, even with AM/PM display) |
HH | the hour with a leading zero (00 to 23, even with AM/PM display) |
m | the minute without a leading zero (0 to 59) |
mm | the minute with a leading zero (00 to 59) |
s | the whole second, without any leading zero (0 to 59) |
ss | the whole second, with a leading zero where applicable (00 to 59) |
z | the fractional part of the second, to go after a decimal point, without trailing zeroes (0 to 999). Thus "s.z " reports the seconds to full available (millisecond) precision without trailing zeroes. |
zzz | the fractional part of the second, to millisecond precision, including trailing zeroes where applicable (000 to 999). |
AP or A | use AM/PM display. A/AP will be replaced by either QLocale::amText() or QLocale::pmText(). |
ap or a | use am/pm display. a/ap will be replaced by a lower-case version of QLocale::amText() or QLocale::pmText(). |
t | the timezone (for example "CEST") |
All other input characters will be ignored. Any sequence of characters that are enclosed in single quotes will be treated as text and not be used as an expression. Two consecutive single quotes ("''") are replaced by a singlequote in the output. Formats without separators (e.g. "HHmm") are currently not supported.
Example format strings (assuming that the QTime is 14:13:09.042 and the system locale is en_US
)
Format | Result |
---|---|
hh:mm:ss.zzz | 14:13:09.042 |
h:m:s ap | 2:13:9 pm |
H:m:s a | 14:13:9 pm |
If the time is invalid, an empty string will be returned. If format is empty, the default format "hh:mm:ss" is used.
See also fromString(), QDate::toString(), QDateTime::toString(), and QLocale::toString().
sourcepub unsafe fn to_string(&self) -> CppBox<QString>
pub unsafe fn to_string(&self) -> CppBox<QString>
This is an overloaded function.
Calls C++ function: QString QTime::toString() const
.
This is an overloaded function.
Returns the time as a string. The format parameter determines the format of the string.
If format is Qt::TextDate, the string format is HH:mm:ss; e.g. 1 second before midnight would be "23:59:59".
If format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates, represented by HH:mm:ss. To include milliseconds in the ISO 8601 date, use the format Qt::ISODateWithMs, which corresponds to HH:mm:ss.zzz.
If the format is Qt::SystemLocaleShortDate or Qt::SystemLocaleLongDate, the string format depends on the locale settings of the system. Identical to calling QLocale::system().toString(time, QLocale::ShortFormat) or QLocale::system().toString(time, QLocale::LongFormat).
If the format is Qt::DefaultLocaleShortDate or Qt::DefaultLocaleLongDate, the string format depends on the default application locale. This is the locale set with QLocale::setDefault(), or the system locale if no default locale has been set. Identical to calling
QLocale().toString(time, QLocale::ShortFormat) or QLocale().toString(time, QLocale::LongFormat).
If the format is Qt::RFC2822Date, the string is formatted in an RFC 2822 compatible way. An example of this formatting is "23:59:20".
If the time is invalid, an empty string will be returned.
See also fromString(), QDate::toString(), QDateTime::toString(), and QLocale::toString().
sourcepub unsafe fn to_string_q_string_view(
&self,
format: impl CastInto<Ref<QStringView>>
) -> CppBox<QString>
Available on cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn to_string_q_string_view( &self, format: impl CastInto<Ref<QStringView>> ) -> CppBox<QString>
cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.This is an overloaded function.
Calls C++ function: QString QTime::toString(QStringView format) const
.
Warning: no exact match found in C++ documentation. Below is the C++ documentation for QString QTime::toString(Qt::DateFormat format = Qt::TextDate) const
:
This is an overloaded function.
Returns the time as a string. The format parameter determines the format of the string.
If format is Qt::TextDate, the string format is HH:mm:ss; e.g. 1 second before midnight would be "23:59:59".
If format is Qt::ISODate, the string format corresponds to the ISO 8601 extended specification for representations of dates, represented by HH:mm:ss. To include milliseconds in the ISO 8601 date, use the format Qt::ISODateWithMs, which corresponds to HH:mm:ss.zzz.
If the format is Qt::SystemLocaleShortDate or Qt::SystemLocaleLongDate, the string format depends on the locale settings of the system. Identical to calling QLocale::system().toString(time, QLocale::ShortFormat) or QLocale::system().toString(time, QLocale::LongFormat).
If the format is Qt::DefaultLocaleShortDate or Qt::DefaultLocaleLongDate, the string format depends on the default application locale. This is the locale set with QLocale::setDefault(), or the system locale if no default locale has been set. Identical to calling
QLocale().toString(time, QLocale::ShortFormat) or QLocale().toString(time, QLocale::LongFormat).
If the format is Qt::RFC2822Date, the string is formatted in an RFC 2822 compatible way. An example of this formatting is "23:59:20".
If the time is invalid, an empty string will be returned.
See also fromString(), QDate::toString(), QDateTime::toString(), and QLocale::toString().
Trait Implementations§
source§impl CppDeletable for QTime
impl CppDeletable for QTime
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QTime class provides clock time functions.
Calls C++ function: [destructor] void QTime::~QTime()
.
The QTime class provides clock time functions.
A QTime object contains a clock time, i.e. the number of hours, minutes, seconds, and milliseconds since midnight. It can read the current time from the system clock and measure a span of elapsed time. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.
QTime uses the 24-hour clock format; it has no concept of AM/PM. Unlike QDateTime, QTime knows nothing about time zones or daylight-saving time (DST).
A QTime object is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static function currentTime(), which creates a QTime object that contains the system's local time. Note that the accuracy depends on the accuracy of the underlying operating system; not all systems provide 1-millisecond accuracy.
The hour(), minute(), second(), and msec() functions provide access to the number of hours, minutes, seconds, and milliseconds of the time. The same information is provided in textual format by the toString() function.
QTime provides a full set of operators to compare two QTime objects. QTime A is considered smaller than QTime B if A is earlier than B.
The addSecs() and addMSecs() functions provide the time a given number of seconds or milliseconds later than a given time. Correspondingly, the number of seconds or milliseconds between two times can be found using secsTo() or msecsTo().
QTime can be used to measure a span of elapsed time using the start(), restart(), and elapsed() functions.