QGraphicsSimpleTextItem Class
QGraphicsSimpleTextItem 클래스는 QGraphicsScene...에 추가할 수 있는 간단한 텍스트 경로 항목을 제공합니다. ...
헤더: | #include <QGraphicsSimpleTextItem> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
상속합니다: | QAbstractGraphicsShapeItem |
공용 유형
enum | anonymous { Type } |
공용 함수
QGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr) | |
QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = nullptr) | |
virtual | ~QGraphicsSimpleTextItem() |
QFont | font() const |
void | setFont(const QFont &font) |
void | setText(const QString &text) |
QString | text() const |
재구현된 공용 함수
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) override |
virtual QPainterPath | shape() const override |
virtual int | type() const override |
상세 설명
항목의 텍스트를 설정하려면 QGraphicsSimpleTextItem의 생성자에 QString 를 전달하거나 setText()를 호출하여 나중에 텍스트를 변경할 수 있습니다. 텍스트 채우기 색상을 설정하려면 setBrush()를 호출합니다.
setBrush()는 텍스트 채우기(즉, 텍스트 색상)를 설정하고 setPen()는 텍스트 윤곽선을 그리는 데 사용할 펜을 설정합니다. (후자는 특히 펜이 복잡하거나 텍스트 내용이 긴 항목의 경우 속도가 느려질 수 있습니다.) 간단한 텍스트 라인만 그리려면 setBrush()만 호출하고 펜은 설정하지 않은 상태로 두어야 합니다(QGraphicsSimpleTextItem의 펜은 기본적으로 Qt::NoPen 입니다).
QGraphicsSimpleTextItem은 텍스트의 포맷 크기와 관련 글꼴을 사용하여 boundingRect(), shape() 및 contains()의 합리적인 구현을 제공합니다. setFont ()를 호출하여 글꼴을 설정할 수 있습니다.
대신 전체 텍스트 제어 기능을 제공하는 QGraphicsTextItem 을 사용할 수 있습니다.
QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, 및 그래픽 보기 프레임워크도참조하세요 .
회원 유형 문서
enum QGraphicsSimpleTextItem::anonymous
가상 type() 함수가 반환하는 값입니다.
상수 | Value | 설명 |
---|---|---|
QGraphicsSimpleTextItem::Type | 9 | 그래픽 단순 텍스트 항목 |
멤버 함수 문서
[explicit]
QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr)
QGraphicsSimpleTextItem을 구축합니다.
parent 은 QGraphicsItem 의 생성자에게 전달됩니다.
QGraphicsScene::addItem()도 참조하십시오 .
[explicit]
QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = nullptr)
text 을 기본 일반 텍스트로 사용하여 QGraphicsSimpleTextItem을 구축합니다.
parent 는 QGraphicsItem 의 생성자에 전달됩니다.
QGraphicsScene::addItem()도 참조하십시오 .
[virtual noexcept]
QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()
QGraphicsSimpleTextItem 를 파괴합니다.
[override virtual]
QRectF QGraphicsSimpleTextItem::boundingRect() const
재구현합니다: QGraphicsItem::boundingRect() const.
[override virtual]
bool QGraphicsSimpleTextItem::contains(const QPointF &point) const
재구현합니다: QGraphicsItem::contains(const QPointF &point) const.
QFont QGraphicsSimpleTextItem::font() const
항목의 텍스트를 그리는 데 사용되는 글꼴을 반환합니다.
setFont()도 참조하세요 .
[override virtual]
bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const
재구현합니다: QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const.
[override virtual]
QPainterPath QGraphicsSimpleTextItem::opaqueArea() const
재구현합니다: QAbstractGraphicsShapeItem::opaqueArea() const.
[override virtual]
void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
재구현합니다: QGraphicsItem::paint(QPainter *페인터, const Q스타일옵션그래픽아이템 *옵션, Q위젯 *위젯).
void QGraphicsSimpleTextItem::setFont(const QFont &font)
항목의 텍스트를 그리는 데 사용되는 글꼴을 font 으로 설정합니다.
font()도 참조하세요 .
void QGraphicsSimpleTextItem::setText(const QString &text)
항목의 텍스트를 text 로 설정합니다. 텍스트가 일반 텍스트로 표시됩니다. 줄 바꿈 문자('\n')와 QChar::LineSeparator 유형의 문자를 포함하면 항목의 텍스트가 여러 줄로 나뉩니다.
text()도 참조하십시오 .
[override virtual]
QPainterPath QGraphicsSimpleTextItem::shape() const
재구현합니다: QGraphicsItem::shape() const.
QString QGraphicsSimpleTextItem::text() const
항목의 텍스트를 반환합니다.
setText()도 참조하세요 .
[override virtual]
int QGraphicsSimpleTextItem::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.