def
__eq__
(other)
def
__ge__
(other)
def
__gt__
(other)
def
__le__
(other)
def
__lt__
(other)
def
__ne__
(other)
def
__reduce__
()
def
__repr__
()
def
addMSecs
(ms)
def
addSecs
(secs)
def
elapsed
()
def
hour
()
def
isNull
()
def
isValid
()
def
minute
()
def
msec
()
def
msecsSinceStartOfDay
()
def
msecsTo
(arg__1)
def
restart
()
def
second
()
def
secsTo
(arg__1)
def
setHMS
(h, m, s[, ms=0])
def
start
()
def
toPython
()
def
toString
([f=Qt.TextDate])
def
toString
(format)
def
currentTime
()
def
fromMSecsSinceStartOfDay
(msecs)
def
fromString
(s, format)
def
fromString
(s[, f=Qt.TextDate])
def
isValid
(h, m, s[, ms=0])
A
QTimeobject contains a clock time, which it can express as the numbers of hours, minutes, seconds, and milliseconds since midnight. It provides functions for comparing times and for manipulating a time by adding a number of milliseconds.
QTimeuses the 24-hour clock format; it has no concept of AM/PM. UnlikeQDateTime,QTimeknows nothing about time zones or daylight-saving time (DST).A
QTimeobject is typically created either by giving the number of hours, minutes, seconds, and milliseconds explicitly, or by using the static functioncurrentTime(), which creates aQTimeobject that represents the system’s local time.
hour(),minute(),second(),和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 thetoString()函数。
addSecs()andaddMSecs()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 usingsecsTo()ormsecsTo().
QTimeprovides a full set of operators to compare twoQTimeobjects; an earlier time is considered smaller than a later one; if A.msecsTo(B) is positive, then A < B.
QTime
¶
QTime(QTime)
QTime(h, m[, s=0[, ms=0]])
- param h
int- param m
int- param ms
int- param s
int- param QTime
构造 null 时间对象。对于 null 时间,
isNull()
返回
true
and
isValid()
返回
false
. If you need a zero time, use
QTime
(0, 0). For the start of a day, see
startOfDay()
.
构造时间采用小时
h
,分钟
m
,秒
s
和毫秒
ms
.
h
必须在范围 0 到 23,
m
and
s
必须在范围 0 到 59,和
ms
必须在范围 0 到 999。
另请参阅
PySide2.QtCore.QTime.
TimeFlag
¶
PySide2.QtCore.QTime.
__reduce__
(
)
¶
PyObject
PySide2.QtCore.QTime.
__repr__
(
)
¶
PyObject
PySide2.QtCore.QTime.
addMSecs
(
ms
)
¶
ms
–
int
返回
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()
范例。
返回 null 时间若此时间无效。
另请参阅
PySide2.QtCore.QTime.
addSecs
(
secs
)
¶
secs
–
int
返回
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.
返回 null 时间若此时间无效。
范例:
n = QTime(14, 0, 0) # n == 14:00:00
t = QTime()
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
另请参阅
PySide2.QtCore.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.
Furthermore, only increases within each day; it shall drop by 24 hours each time midnight passes; and, beside this, changes in it may not correspond to elapsed time, if a daylight-saving transition intervenes.
PySide2.QtCore.QTime.
elapsed
(
)
¶
int
注意
此函数被弃用。
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.
PySide2.QtCore.QTime.
fromMSecsSinceStartOfDay
(
msecs
)
¶
msecs
–
int
返回新
QTime
instance with the time set to the number of
msecs
since the start of the day, i.e. since 00:00:00.
若
msecs
falls outside the valid range an invalid
QTime
将被返回。
PySide2.QtCore.QTime.
fromString
(
s
[
,
f=Qt.TextDate
]
)
¶
s – unicode
f
–
DateFormat
PySide2.QtCore.QTime.
hour
(
)
¶
int
Returns the hour part (0 to 23) of the time.
返回 -1,若时间无效。
PySide2.QtCore.QTime.
isNull
(
)
¶
bool
返回
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.
另请参阅
PySide2.QtCore.QTime.
isValid
(
)
¶
bool
返回
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.
另请参阅
PySide2.QtCore.QTime.
isValid
(
h
,
m
,
s
[
,
ms=0
]
)
¶
h
–
int
m
–
int
s
–
int
ms
–
int
bool
这是重载函数。
返回
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.
范例:
QTime.isValid(21, 10, 30) # returns True
QTime.isValid(22, 5, 62) # returns False
PySide2.QtCore.QTime.
minute
(
)
¶
int
Returns the minute part (0 to 59) of the time.
返回 -1,若时间无效。
PySide2.QtCore.QTime.
msec
(
)
¶
int
Returns the millisecond part (0 to 999) of the time.
返回 -1,若时间无效。
PySide2.QtCore.QTime.
msecsSinceStartOfDay
(
)
¶
int
Returns the number of msecs since the start of the day, i.e. since 00:00:00.
PySide2.QtCore.QTime.
msecsTo
(
arg__1
)
¶
arg__1
–
QTime
int
Returns the number of milliseconds from this time to
t
。若
t
is earlier than this time, the number of milliseconds returned is negative.
因为
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.
另请参阅
PySide2.QtCore.QTime.
__ne__
(
other
)
¶
other
–
QTime
bool
返回
true
if this time is different from
t
;否则返回
false
.
PySide2.QtCore.QTime.
restart
(
)
¶
int
注意
此函数被弃用。
Sets this time to the current time and returns the number of milliseconds that have elapsed since the last time
start()
or 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 for each later measurement.
Note that the counter wraps to zero 24 hours after the last call to
start()
or .
警告
If the system’s clock setting has been changed since the last time
start()
or was called, the result is undefined. This can happen when daylight-saving time is turned on or off.
PySide2.QtCore.QTime.
second
(
)
¶
int
Returns the second part (0 to 59) of the time.
返回 -1,若时间无效。
PySide2.QtCore.QTime.
secsTo
(
arg__1
)
¶
arg__1
–
QTime
int
Returns the number of seconds from this time to
t
。若
t
is earlier than this time, the number of seconds returned is negative.
因为
QTime
measures time within a day and there are 86400 seconds in a day, the result is always between -86400 and 86400.
does not take into account any milliseconds.
Returns 0 if either time is invalid.
PySide2.QtCore.QTime.
setHMS
(
h
,
m
,
s
[
,
ms=0
]
)
¶
h
–
int
m
–
int
s
–
int
ms
–
int
bool
Sets the time to hour
h
,分钟
m
,秒
s
和毫秒
ms
.
h
必须在范围 0 到 23,
m
and
s
必须在范围 0 到 59,和
ms
must be in the range 0 to 999. Returns
true
if the set time is valid; otherwise returns
false
.
另请参阅
PySide2.QtCore.QTime.
start
(
)
¶
注意
此函数被弃用。
Sets this time to the current time. This is practical for timing:
t = QTime()
t.start()
some_lengthy_task()
print ("Time elapsed: %d ms" % t.elapsed())
PySide2.QtCore.QTime.
toPython
(
)
¶
PyObject
PySide2.QtCore.QTime.
toString
(
[
f=Qt.TextDate
]
)
¶
f
–
DateFormat
unicode
这是重载函数。
Returns the time as a string. The
format
parameter determines the format of the string.
若
format
is
TextDate
, the string format is HH:mm:ss; e.g. 1 second before midnight would be “23:59:59”.
若
format
is
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
ISODateWithMs
, which corresponds to HH:mm:ss.zzz.
format
options
SystemLocaleDate
:,
SystemLocaleShortDate
and
SystemLocaleLongDate
shall be removed in Qt 6. Their use should be replaced with:
ShortFormat)
or
LongFormat)
.
format
options
LocaleDate
,
DefaultLocaleShortDate
and
DefaultLocaleLongDate
shall be removed in Qt 6. Their use should be replaced with:
ShortFormat)
or
LongFormat)
.
若
format
is
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.
PySide2.QtCore.QTime.
toString
(
format
)
¶
format – unicode
unicode