QGraphicsPolygonItem Class
QGraphicsPolygonItem 类提供了一个多边形项,您可以将其添加到QGraphicsScene... 更多...
Header: | #include <QGraphicsPolygonItem> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QAbstractGraphicsShapeItem |
公共类型
enum | anonymous { Type } |
公共函数
QGraphicsPolygonItem(QGraphicsItem *parent = nullptr) | |
QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent = nullptr) | |
virtual | ~QGraphicsPolygonItem() |
Qt::FillRule | fillRule() const |
QPolygonF | polygon() const |
void | setFillRule(Qt::FillRule rule) |
void | setPolygon(const QPolygonF &polygon) |
重新实现的公共函数
virtual QRectF | boundingRect() const override |
virtual bool | contains(const QPointF &point) const override |
virtual bool | isObscuredBy(const QGraphicsItem *item) const override |
virtual QPainterPath | opaqueArea() const override |
virtual void | paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override |
virtual QPainterPath | shape() const override |
virtual int | type() const override |
详细说明
要设置项目的多边形,请将QPolygonF 传递给 QGraphicsPolygonItem 的构造函数,或调用setPolygon() 函数。polygon() 函数将返回当前多边形。
QGraphicsPolygonItem 使用多边形和笔宽来合理实现boundingRect(),shape(), 和contains().paint() 函数使用项的相关笔和笔刷绘制多边形,您可以通过调用setPen() 和setBrush() 函数设置笔和笔刷。
另请参阅 QGraphicsPathItem,QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsTextItem,QGraphicsLineItem,QGraphicsPixmapItem 和图形视图框架。
成员类型文档
enum QGraphicsPolygonItem::anonymous
虚拟type() 函数返回的值。
常量 | 值 | 说明 |
---|---|---|
QGraphicsPolygonItem::Type | 5 | 图形多边形项 |
成员函数文档
[explicit]
QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent = nullptr)
构造一个 QGraphicsPolygonItem。parent 传递给QAbstractGraphicsShapeItem 的构造函数。
另请参阅 QGraphicsScene::addItem().
[explicit]
QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent = nullptr)
构造一个 QGraphicsPolygonItem,默认多边形为polygon 。parent 将传递给QAbstractGraphicsShapeItem 的构造函数。
另请参阅 QGraphicsScene::addItem().
[virtual noexcept]
QGraphicsPolygonItem::~QGraphicsPolygonItem()
[override virtual]
QRectF QGraphicsPolygonItem::boundingRect() const
重实现:QGraphicsItem::boundingRect() const.
[override virtual]
bool QGraphicsPolygonItem::contains(const QPointF &point) const
重实现:QGraphicsItem::contains(const QPointF &point) const.
Qt::FillRule QGraphicsPolygonItem::fillRule() const
返回多边形的填充规则。默认填充规则是Qt::OddEvenFill 。
另请参阅 setFillRule()、QPainterPath::fillRule() 和QPainter::drawPolygon()。
[override virtual]
bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const
重实现:QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const.
[override virtual]
QPainterPath QGraphicsPolygonItem::opaqueArea() const
重实现:QAbstractGraphicsShapeItem::opaqueArea() const.
[override virtual]
void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
重实现:QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)。
QPolygonF QGraphicsPolygonItem::polygon() const
返回项目的多边形,如果没有设置多边形,则返回空多边形。
另请参阅 setPolygon()。
void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule)
将多边形的填充规则设置为rule 。默认填充规则为Qt::OddEvenFill 。
另请参阅 fillRule()、QPainterPath::fillRule() 和QPainter::drawPolygon()。
void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)
将项目的多边形设置为给定的polygon 。
另请参阅 polygon()。
[override virtual]
QPainterPath QGraphicsPolygonItem::shape() const
重实现:QGraphicsItem::shape() const.
[override virtual]
int QGraphicsPolygonItem::type() const
重实现:QGraphicsItem::type() const.
© 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.