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 { 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 |
詳細な説明
項目のテキストを設定するには、QString を QGraphicsSimpleTextItem のコンストラクタに渡すか、後でsetText() を呼び出してテキストを変更します。テキストの塗りつぶし色を設定するには、setBrush() を呼び出します。
このシンプルなテキストアイテムは、塗りつぶしとアウトラインの両方を設定できます。setBrush() はテキストの塗りつぶし(つまり、テキストの色)を設定し、setPen() はテキストのアウトラインの描画に使用されるペンを設定します。 (後者は、特に複雑なペンや、テキストコンテンツが長いアイテムの場合、処理に時間がかかることがあります。)単純なテキスト行を描画したいだけの場合は、setBrush() のみを呼び出し、ペンは設定しないままにしておくべきです。QGraphicsSimpleTextItem のペンは、デフォルトでQt::NoPen です。
QGraphicsSimpleTextItemは、テキストのフォーマット済みサイズと関連付けられたフォントを使用して、boundingRect()、shape()、およびcontains()の適切な実装を提供します。フォントはsetFont()を呼び出すことで設定できます。
QGraphicsSimpleText はリッチテキストを表示しません。代わりに、完全なテキスト制御機能を提供するQGraphicsTextItem を使用できます。

QGraphicsTextItem 、QGraphicsPathItem 、QGraphicsRectItem 、QGraphicsEllipseItem 、QGraphicsPixmapItem 、QGraphicsPolygonItem 、QGraphicsLineItem 、およびGraphics View Frameworkも参照してください 。
メンバ関数のドキュメント
[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 *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)を再実装します。
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 を再実装します。
© 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.