QMediaTimeRange Class
QMediaTimeRange 类表示一组零个或多个不相连的时间间隔。更多
Header: | #include <QMediaTimeRange> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
注意:该类中的所有函数都是可重入的。
公共类型
struct | Interval |
公共函数
QMediaTimeRange() | |
QMediaTimeRange(const QMediaTimeRange::Interval &interval) | |
QMediaTimeRange(qint64 start, qint64 end) | |
QMediaTimeRange(const QMediaTimeRange &range) | |
QMediaTimeRange(QMediaTimeRange &&other) | |
~QMediaTimeRange() | |
void | addInterval(const QMediaTimeRange::Interval &interval) |
void | addInterval(qint64 start, qint64 end) |
void | addTimeRange(const QMediaTimeRange &range) |
void | clear() |
bool | contains(qint64 time) const |
qint64 | earliestTime() const |
QList<QMediaTimeRange::Interval> | intervals() const |
bool | isContinuous() const |
bool | isEmpty() const |
qint64 | latestTime() const |
void | removeInterval(const QMediaTimeRange::Interval &interval) |
void | removeInterval(qint64 start, qint64 end) |
void | removeTimeRange(const QMediaTimeRange &range) |
void | swap(QMediaTimeRange &other) |
QMediaTimeRange & | operator+=(const QMediaTimeRange &other) |
QMediaTimeRange & | operator+=(const QMediaTimeRange::Interval &interval) |
QMediaTimeRange & | operator-=(const QMediaTimeRange &other) |
QMediaTimeRange & | operator-=(const QMediaTimeRange::Interval &interval) |
QMediaTimeRange & | operator=(QMediaTimeRange &&other) |
QMediaTimeRange & | operator=(const QMediaTimeRange &other) |
QMediaTimeRange & | operator=(const QMediaTimeRange::Interval &interval) |
相关非成员
bool | operator!=(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs) |
QMediaTimeRange | operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2) |
QMediaTimeRange | operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2) |
bool | operator==(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs) |
详细说明
earliestTime(),latestTime(),intervals() 和isEmpty() 方法用于获取有关当前时间范围的信息。
addInterval(),removeInterval() 和clear() 方法用于修改当前时间范围。
在添加或删除时间范围内的时间间隔时,时间范围内的现有时间间隔可能会被扩展、修剪、删除、合并或分割,以确保时间范围内的所有时间间隔保持不同和不相交。因此,从时间范围中添加或删除的所有区间都必须是normal 。
另请参阅 QMediaTimeRange::Interval 。
成员函数文档
QMediaTimeRange::QMediaTimeRange()
构造一个空时间范围。
QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange::Interval &interval)
构造一个包含初始时间间隔interval 的时间范围。
如果interval 不是normal ,生成的时间范围将是空的。
另请参阅 addInterval() 。
[explicit]
QMediaTimeRange::QMediaTimeRange(qint64 start, qint64 end)
构造一个时间范围,其中包含从start 到end (含)的初始时间间隔。
如果时间间隔不是normal ,生成的时间范围将是空的。
另请参阅 addInterval()。
[noexcept]
QMediaTimeRange::QMediaTimeRange(const QMediaTimeRange &range)
通过复制另一个时间range 构建一个时间范围。
[noexcept]
QMediaTimeRange::QMediaTimeRange(QMediaTimeRange &&other)
从other 开始,构建一个时间范围。
[noexcept]
QMediaTimeRange::~QMediaTimeRange()
毁灭者
void QMediaTimeRange::addInterval(const QMediaTimeRange::Interval &interval)
将指定的interval 添加到时间范围。
添加非normal 的时间间隔无效,将被忽略。
如果指定的时间间隔与时间范围内现有的时间间隔相邻或重叠,这些时间间隔将被合并。
此操作需要线性时间。
另请参见 removeInterval()。
void QMediaTimeRange::addInterval(qint64 start, qint64 end)
这是一个重载函数。
将start 和end 指定的时间间隔添加到时间范围。
另请参见 addInterval().
void QMediaTimeRange::addTimeRange(const QMediaTimeRange &range)
将range 中的每个时间间隔添加到该时间范围。
相当于为range 中的每个时间间隔调用addInterval() 。
void QMediaTimeRange::clear()
删除时间范围内的所有时间间隔。
另请参阅 removeInterval().
bool QMediaTimeRange::contains(qint64 time) const
如果指定的time 位于时间范围内,则返回 true。
qint64 QMediaTimeRange::earliestTime() const
返回时间范围内的最早时间。
对于空时间范围,该值等于零。
另请参阅 latestTime()。
QList<QMediaTimeRange::Interval> QMediaTimeRange::intervals() const
返回该时间范围覆盖的时间间隔列表。
bool QMediaTimeRange::isContinuous() const
如果时间范围包含一个连续区间,则返回 true。也就是说,在时间范围内有一个或更少的不连续区间。
bool QMediaTimeRange::isEmpty() const
如果时间范围内没有时间间隔,则返回 true。
另请参阅 intervals()。
qint64 QMediaTimeRange::latestTime() const
返回时间范围内的最新时间。
对于空时间范围,该值等于零。
另请参阅 earliestTime()。
void QMediaTimeRange::removeInterval(const QMediaTimeRange::Interval &interval)
从时间范围中删除指定的interval 。
删除不属于normal 的时间间隔是无效的,将被忽略。
时间范围内的区间将被修剪、分割或删除,这样时间范围内的区间就不会包含目标区间的任何部分。
此操作需要线性时间。
另请参见 addInterval()。
void QMediaTimeRange::removeInterval(qint64 start, qint64 end)
这是一个重载函数。
从时间范围中删除start 和end 指定的时间间隔。
另请参见 removeInterval().
void QMediaTimeRange::removeTimeRange(const QMediaTimeRange &range)
从时间范围中删除range 中的每个时间间隔。
相当于为range 中的每个时间间隔调用removeInterval() 。
[noexcept]
void QMediaTimeRange::swap(QMediaTimeRange &other)
将当前实例与other 互换。
QMediaTimeRange &QMediaTimeRange::operator+=(const QMediaTimeRange &other)
将other 中的每个时间间隔添加到时间范围并返回结果。
QMediaTimeRange &QMediaTimeRange::operator+=(const QMediaTimeRange::Interval &interval)
将指定的interval 添加到时间范围并返回结果。
QMediaTimeRange &QMediaTimeRange::operator-=(const QMediaTimeRange &other)
从时间范围中删除other 中的每个时间间隔,并返回结果。
QMediaTimeRange &QMediaTimeRange::operator-=(const QMediaTimeRange::Interval &interval)
从时间范围中删除指定的interval ,并返回结果。
[noexcept]
QMediaTimeRange &QMediaTimeRange::operator=(QMediaTimeRange &&other)
将other 移入该时间范围。
[noexcept]
QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange &other)
获取other 时间范围的副本并返回自身。
QMediaTimeRange &QMediaTimeRange::operator=(const QMediaTimeRange::Interval &interval)
将时间范围设置为单个连续时间间隔,interval 。
相关非会员
bool operator!=(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
如果lhs 中的一个或多个区间不在rhs 中,则返回 true。
QMediaTimeRange operator+(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
Returns a time range containing the union betweenr1 andr2.
QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
返回包含r2 减去r1 的时间范围。
bool operator==(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
如果lhs 中的所有区间都出现在rhs 中,则返回 true。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.