QPolygonF Class
QPolygonF 类提供了一个使用浮点精度的点列表。更多
头文件: | #include <QPolygonF> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QList |
- 所有成员的列表,包括继承成员
- QPolygonF 属于绘制类和隐式共享类。
注意:该类中的所有函数都是可重入的。
公共函数
QPolygonF() | |
QPolygonF(const QList<QPointF> &points) | |
QPolygonF(const QPolygon &polygon) | |
QPolygonF(const QRectF &rectangle) | |
QRectF | boundingRect() const |
bool | containsPoint(const QPointF &point, Qt::FillRule fillRule) const |
QPolygonF | intersected(const QPolygonF &r) const |
bool | intersects(const QPolygonF &p) const |
bool | isClosed() const |
QPolygonF | subtracted(const QPolygonF &r) const |
void | swap(QPolygonF &other) |
QPolygon | toPolygon() const |
void | translate(const QPointF &offset) |
void | translate(qreal dx, qreal dy) |
QPolygonF | translated(const QPointF &offset) const |
QPolygonF | translated(qreal dx, qreal dy) const |
QPolygonF | united(const QPolygonF &r) const |
QVariant | operator QVariant() const |
相关非成员
QDataStream & | operator<<(QDataStream &stream, const QPolygonF &polygon) |
QDataStream & | operator>>(QDataStream &stream, QPolygonF &polygon) |
详细描述
QPolygonF 是QList<QPointF>。向 QPolygonF 添加点的最简单方法是使用其流操作符,如下图所示:
除了QList 提供的函数外,QPolygonF 还提供了用于几何操作的boundingRect() 和translate() 函数。使用QTransform::map() 函数可对 QPolygonF 进行更一般的变换。
QPolygonF 还提供isClosed() 函数来确定多边形的起点和终点是否相同,并提供toPolygon() 函数来返回该多边形的整数精度副本。
QPolygonF 类是隐式共享的。
另请参见 QList,QPolygon, 和QLineF 。
成员函数文档
[constexpr noexcept]
QPolygonF::QPolygonF()
构造一个没有点的多边形。
另请参见 QList::isEmpty()。
QPolygonF::QPolygonF(const QList<QPointF> &points)
构建包含指定points 的多边形。
QPolygonF::QPolygonF(const QPolygon &polygon)
根据指定的基于整数的polygon 构建基于浮点的多边形。
另请参见 toPolygon().
QPolygonF::QPolygonF(const QRectF &rectangle)
根据指定的rectangle 构建一个封闭的多边形。
多边形包含矩形的四个顶点,以顺时针的顺序从左上顶点开始,到左上顶点结束。
另请参阅 isClosed() 。
QRectF QPolygonF::boundingRect() const
返回多边形的边界矩形,如果多边形为空,则返回QRectF(0,0,0,0)。
另请参见 QList::isEmpty()。
bool QPolygonF::containsPoint(const QPointF &point, Qt::FillRule fillRule) const
如果根据指定的fillRule ,给定的point 位于多边形内部,则返回true
;否则返回false
。
QPolygonF QPolygonF::intersected(const QPolygonF &r) const
返回一个多边形,该多边形与r 相交。
多边形的集合操作将把多边形视为区域。非封闭多边形将被视为隐式封闭多边形。
另请参见 intersects()。
bool QPolygonF::intersects(const QPolygonF &p) const
如果当前多边形与给定多边形相交,则返回true
p 。如果当前多边形包含或被p 的任何部分包含,也会返回true
。
对多边形进行设置操作将把多边形视为区域。非封闭多边形将被视为隐式封闭多边形。
另请参见 intersected()。
bool QPolygonF::isClosed() const
如果多边形是封闭的,则返回true
;否则返回false
。
如果多边形的起点和终点相等,则表示该多边形是封闭的。
另请参阅 QList::first() 和QList::last()。
QPolygonF QPolygonF::subtracted(const QPolygonF &r) const
返回从r 减去此多边形的多边形。
对多边形进行设置操作时,会将多边形视为区域。非封闭多边形将被视为隐式封闭多边形。
void QPolygonF::swap(QPolygonF &other)
将此多边形与other 互换。这一操作速度非常快,而且从未出现过故障。
QPolygon QPolygonF::toPolygon() const
通过将每个QPointF 转换为QPoint ,创建并返回QPolygon 。
另请参阅 QPointF::toPoint() 。
void QPolygonF::translate(const QPointF &offset)
用给定的offset 平移多边形中的所有点。
另请参见 translated() 。
void QPolygonF::translate(qreal dx, qreal dy)
这是一个重载函数。
以 (dx,dy) 的方式平移多边形中的所有点。
另请参见 translated().
QPolygonF QPolygonF::translated(const QPointF &offset) const
返回多边形的副本,该副本按给定的offset 进行平移。
另请参见 translate()。
QPolygonF QPolygonF::translated(qreal dx, qreal dy) const
这是一个重载函数。
返回被 (dx,dy) 平移的多边形的副本。
另请参见 translate().
QPolygonF QPolygonF::united(const QPolygonF &r) const
返回一个多边形,它是此多边形与r 的结合。
多边形的集合操作将把多边形视为区域。非封闭多边形将被视为隐式封闭多边形。
另请参阅 intersected() 和subtracted()。
QVariant QPolygonF::operator QVariant() const
以QVariant 的形式返回多边形。
相关非会员
QDataStream &operator<<(QDataStream &stream, const QPolygonF &polygon)
将给定的polygon 写入给定的stream ,并返回对该数据流的引用。
另请参阅 序列化 Qt 数据类型。
QDataStream &operator>>(QDataStream &stream, QPolygonF &polygon)
将多边形从给定的stream 读取到给定的polygon 中,并返回对该数据流的引用。
另请参阅 序列化 Qt 数据类型。
© 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.