QGraphicsRectItem Class
QGraphicsRectItem 클래스는 QGraphicsScene 에 추가할 수 있는 사각형 항목을 제공합니다. 더 보기...
| 헤더: | #include <QGraphicsRectItem> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 상속받는 것: | QAbstractGraphicsShapeItem |
공개 유형
| enum { Type } |
공개 함수
| QGraphicsRectItem(QGraphicsItem *parent = nullptr) | |
| QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr) | |
| QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr) | |
| virtual | ~QGraphicsRectItem() |
| QRectF | rect() const |
| void | setRect(const QRectF &rectangle) |
| void | setRect(qreal x, qreal y, qreal width, qreal height) |
재구현된 공용 함수
| 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 |
상세 설명
항목의 사각형을 설정하려면 QRectF 를 QGraphicsRectItem의 생성자에 전달하거나, setRect() 함수를 호출하십시오. rect() 함수는 현재 사각형을 반환합니다.

QGraphicsRectItem은 사각형과 펜 너비를 사용하여 boundingRect(), shape() 및 contains() 함수를 적절하게 구현합니다. paint() 함수는 항목에 연결된 펜과 브러시를 사용하여 사각형을 그립니다. 이 펜과 브러시는 setPen() 및 setBrush() 함수를 호출하여 설정할 수 있습니다.
참고: 너비나 높이가 음수인 경우와 같이 유효하지 않은 사각형의렌더링 결과는 정의되지 않습니다. 유효한 사각형을 사용하고 있는지 확신할 수 없는 경우(예: 신뢰할 수 없는 출처의 데이터를 사용하여 사각형을 생성하는 경우), QRectF::normalized()를 사용하여 정규화된 사각형을 생성하고, 이를 대신 사용해야 합니다.
QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem 및 Graphics View Framework도참조하십시오 .
멤버 함수 설명서
[explicit] QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent = nullptr)
QGraphicsRectItem 객체를 생성합니다. ` parent `는 ` QAbstractGraphicsShapeItem`의 생성자에 전달됩니다.
QGraphicsScene::addItem()도 참조하십시오 .
[explicit] QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr)
rect 를 기본 사각형으로 사용하여 QGraphicsRectItem을 생성합니다. parent 는 QAbstractGraphicsShapeItem 의 생성자에 전달됩니다.
QGraphicsScene::addItem()도 참조하십시오 .
[explicit] QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr)
(x, y)으로 정의된 기본 사각형과, 지정된 width 및 height 을 사용하여 QGraphicsRectItem을 생성합니다.
parent 는 QAbstractGraphicsShapeItem 의 생성자에 전달됩니다.
QGraphicsScene::addItem()도 참조하십시오 .
[virtual noexcept] QGraphicsRectItem::~QGraphicsRectItem()
QGraphicsRectItem 를 파괴합니다.
[override virtual] QRectF QGraphicsRectItem::boundingRect() const
QGraphicsItem::boundingRect() const를 재구현합니다.
[override virtual] bool QGraphicsRectItem::contains(const QPointF &point) const
QGraphicsItem::contains(const QPointF &point) const를 재구현합니다.
[override virtual] bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const
QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const를 재구현합니다.
[override virtual] QPainterPath QGraphicsRectItem::opaqueArea() const
QAbstractGraphicsShapeItem::opaqueArea() const를 재구현합니다.
[override virtual] void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)를 재구현합니다.
QRectF QGraphicsRectItem::rect() const
항목의 직사각형을 반환합니다.
setRect()도 참조하십시오 .
void QGraphicsRectItem::setRect(const QRectF &rectangle)
항목의 사각형을 지정된 rectangle 로 설정합니다.
rect()도 참조하십시오 .
void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)
항목의 사각형을 (x, y)로 정의된 사각형과, 지정된 width 및 height 로 설정합니다.
이 편의 함수는 다음을 호출하는 것과 동일합니다. setRect(QRectF(x, y, width, height))
rect()도 참조하십시오 .
[override virtual] QPainterPath QGraphicsRectItem::shape() const
QGraphicsItem::shape() const를 재구현합니다.
[override virtual] int QGraphicsRectItem::type() const
QGraphicsItem::type() const를 재구현합니다.
© 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.