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 |
詳細説明
アイテムのテキストを設定するには、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も参照のこと 。
メンバ型ドキュメント
enum QGraphicsSimpleTextItem::anonymous
仮想type() 関数が返す値。
定数 | 値 | 説明 |
---|---|---|
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 *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)。
void QGraphicsSimpleTextItem::setFont(const QFont &font)
アイテムのテキストの描画に使用するフォントをfont に設定します。
font()も参照 。
void QGraphicsSimpleTextItem::setText(const QString &text)
アイテムのテキストをtext に設定します。 テキストはプレーンテキストとして表示されます。改行文字 (' \n') やQChar::LineSeparator 型の文字は、item のテキストを複数行に分割します。
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.