QMediaTimeRange Class
QMediaTimeRange 类表示一组零个或多个互不相交的时间区间。更多内容...
| 头文件: | #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 来构建一个时间范围。
[constexpr noexcept default] 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)
返回一个时间范围,该范围包含r1 和r2 的并集。
QMediaTimeRange operator-(const QMediaTimeRange &r1, const QMediaTimeRange &r2)
返回一个时间范围,该时间范围包含将r2 从r1 中减去后的结果。
bool operator==(const QMediaTimeRange &lhs, const QMediaTimeRange &rhs)
如果lhs 中的所有区间都存在于rhs 中,则返回true。
© 2026 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.