QtBase  v6.3.1
Public Types | Signals | Public Member Functions | Protected Member Functions | Friends | List of all members
QGraphicsTextItem Class Reference

The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text. More...

#include <qgraphicsitem.h>

Inheritance diagram for QGraphicsTextItem:
Inheritance graph
[legend]
Collaboration diagram for QGraphicsTextItem:
Collaboration graph
[legend]

Public Types

enum  { Type = 8 }
 
- Public Types inherited from QGraphicsItem
enum  GraphicsItemFlag {
  ItemIsMovable = 0x1 , ItemIsSelectable = 0x2 , ItemIsFocusable = 0x4 , ItemClipsToShape = 0x8 ,
  ItemClipsChildrenToShape = 0x10 , ItemIgnoresTransformations = 0x20 , ItemIgnoresParentOpacity = 0x40 , ItemDoesntPropagateOpacityToChildren = 0x80 ,
  ItemStacksBehindParent = 0x100 , ItemUsesExtendedStyleOption = 0x200 , ItemHasNoContents = 0x400 , ItemSendsGeometryChanges = 0x800 ,
  ItemAcceptsInputMethod = 0x1000 , ItemNegativeZStacksBehindParent = 0x2000 , ItemIsPanel = 0x4000 , ItemIsFocusScope = 0x8000 ,
  ItemSendsScenePositionChanges = 0x10000 , ItemStopsClickFocusPropagation = 0x20000 , ItemStopsFocusHandling = 0x40000 , ItemContainsChildrenInShape = 0x80000
}
 
enum  GraphicsItemChange {
  ItemPositionChange , ItemVisibleChange = 2 , ItemEnabledChange , ItemSelectedChange ,
  ItemParentChange , ItemChildAddedChange , ItemChildRemovedChange , ItemTransformChange ,
  ItemPositionHasChanged , ItemTransformHasChanged , ItemSceneChange , ItemVisibleHasChanged ,
  ItemEnabledHasChanged , ItemSelectedHasChanged , ItemParentHasChanged , ItemSceneHasChanged ,
  ItemCursorChange , ItemCursorHasChanged , ItemToolTipChange , ItemToolTipHasChanged ,
  ItemFlagsChange , ItemFlagsHaveChanged , ItemZValueChange , ItemZValueHasChanged ,
  ItemOpacityChange , ItemOpacityHasChanged , ItemScenePositionHasChanged , ItemRotationChange ,
  ItemRotationHasChanged , ItemScaleChange , ItemScaleHasChanged , ItemTransformOriginPointChange ,
  ItemTransformOriginPointHasChanged
}
 
enum  CacheMode { NoCache , ItemCoordinateCache , DeviceCoordinateCache }
 
enum  PanelModality { NonModal , PanelModal , SceneModal }
 
enum  { Type = 1 , UserType = 65536 }
 

Signals

void linkActivated (const QString &)
 
void linkHovered (const QString &)
 
- Signals inherited from QGraphicsObject
void parentChanged ()
 
void opacityChanged ()
 
void visibleChanged ()
 
void enabledChanged ()
 
void xChanged ()
 
void yChanged ()
 
void zChanged ()
 
void rotationChanged ()
 
void scaleChanged ()
 
void childrenChanged ()
 
void widthChanged ()
 
void heightChanged ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

 QGraphicsTextItem (QGraphicsItem *parent=nullptr)
 
 QGraphicsTextItem (const QString &text, QGraphicsItem *parent=nullptr)
 
 ~QGraphicsTextItem ()
 
QString toHtml () const
 
void setHtml (const QString &html)
 
QString toPlainText () const
 
void setPlainText (const QString &text)
 
QFont font () const
 
void setFont (const QFont &font)
 
void setDefaultTextColor (const QColor &c)
 
QColor defaultTextColor () const
 
QRectF boundingRect () const override
 
QPainterPath shape () const override
 
bool contains (const QPointF &point) const override
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 
bool isObscuredBy (const QGraphicsItem *item) const override
 
QPainterPath opaqueArea () const override
 
int type () const override
 
void setTextWidth (qreal width)
 
qreal textWidth () const
 
void adjustSize ()
 
void setDocument (QTextDocument *document)
 
QTextDocumentdocument () const
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 
Qt::TextInteractionFlags textInteractionFlags () const
 
void setTabChangesFocus (bool b)
 
bool tabChangesFocus () const
 
void setOpenExternalLinks (bool open)
 
bool openExternalLinks () const
 
void setTextCursor (const QTextCursor &cursor)
 
QTextCursor textCursor () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Public Member Functions inherited from QGraphicsItem
 QGraphicsItem (QGraphicsItem *parent=nullptr)
 
virtual ~QGraphicsItem ()
 
QGraphicsScenescene () const
 
QGraphicsItemparentItem () const
 
QGraphicsItemtopLevelItem () const
 
QGraphicsObjectparentObject () const
 
QGraphicsWidgetparentWidget () const
 
QGraphicsWidgettopLevelWidget () const
 
QGraphicsWidgetwindow () const
 
QGraphicsItempanel () const
 
void setParentItem (QGraphicsItem *parent)
 
QList< QGraphicsItem * > childItems () const
 
bool isWidget () const
 
bool isWindow () const
 
bool isPanel () const
 
QGraphicsObjecttoGraphicsObject ()
 
const QGraphicsObjecttoGraphicsObject () const
 
QGraphicsItemGroupgroup () const
 
void setGroup (QGraphicsItemGroup *group)
 
GraphicsItemFlags flags () const
 
void setFlag (GraphicsItemFlag flag, bool enabled=true)
 
void setFlags (GraphicsItemFlags flags)
 
CacheMode cacheMode () const
 
void setCacheMode (CacheMode mode, const QSize &cacheSize=QSize())
 
PanelModality panelModality () const
 
void setPanelModality (PanelModality panelModality)
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel=nullptr) const
 
QCursor cursor () const
 
void setCursor (const QCursor &cursor)
 
bool hasCursor () const
 
void unsetCursor ()
 
bool isVisible () const
 
bool isVisibleTo (const QGraphicsItem *parent) const
 
void setVisible (bool visible)
 
void hide ()
 
void show ()
 
bool isEnabled () const
 
void setEnabled (bool enabled)
 
bool isSelected () const
 
void setSelected (bool selected)
 
bool acceptDrops () const
 
void setAcceptDrops (bool on)
 
qreal opacity () const
 
qreal effectiveOpacity () const
 
void setOpacity (qreal opacity)
 
Qt::MouseButtons acceptedMouseButtons () const
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 
bool acceptHoverEvents () const
 
void setAcceptHoverEvents (bool enabled)
 
bool acceptTouchEvents () const
 
void setAcceptTouchEvents (bool enabled)
 
bool filtersChildEvents () const
 
void setFiltersChildEvents (bool enabled)
 
bool handlesChildEvents () const
 
void setHandlesChildEvents (bool enabled)
 
bool isActive () const
 
void setActive (bool active)
 
bool hasFocus () const
 
void setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason)
 
void clearFocus ()
 
QGraphicsItemfocusProxy () const
 
void setFocusProxy (QGraphicsItem *item)
 
QGraphicsItemfocusItem () const
 
QGraphicsItemfocusScopeItem () const
 
void grabMouse ()
 
void ungrabMouse ()
 
void grabKeyboard ()
 
void ungrabKeyboard ()
 
QPointF pos () const
 
qreal x () const
 
void setX (qreal x)
 
qreal y () const
 
void setY (qreal y)
 
QPointF scenePos () const
 
void setPos (const QPointF &pos)
 
void setPos (qreal x, qreal y)
 
void moveBy (qreal dx, qreal dy)
 
void ensureVisible (const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin=50, int ymargin=50)
 
QTransform transform () const
 
QTransform sceneTransform () const
 
QTransform deviceTransform (const QTransform &viewportTransform) const
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok=nullptr) const
 
void setTransform (const QTransform &matrix, bool combine=false)
 
void resetTransform ()
 
void setRotation (qreal angle)
 
qreal rotation () const
 
void setScale (qreal scale)
 
qreal scale () const
 
QList< QGraphicsTransform * > transformations () const
 
void setTransformations (const QList< QGraphicsTransform * > &transformations)
 
QPointF transformOriginPoint () const
 
void setTransformOriginPoint (const QPointF &origin)
 
void setTransformOriginPoint (qreal ax, qreal ay)
 
virtual void advance (int phase)
 
qreal zValue () const
 
void setZValue (qreal z)
 
void stackBefore (const QGraphicsItem *sibling)
 
QRectF childrenBoundingRect () const
 
QRectF sceneBoundingRect () const
 
bool isClipped () const
 
QPainterPath clipPath () const
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 
bool isObscured (const QRectF &rect=QRectF()) const
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const
 
qreal boundingRegionGranularity () const
 
void setBoundingRegionGranularity (qreal granularity)
 
void update (const QRectF &rect=QRectF())
 
void update (qreal x, qreal y, qreal width, qreal height)
 
void scroll (qreal dx, qreal dy, const QRectF &rect=QRectF())
 
QPointF mapToItem (const QGraphicsItem *item, const QPointF &point) const
 
QPointF mapToParent (const QPointF &point) const
 
QPointF mapToScene (const QPointF &point) const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const
 
QPolygonF mapToParent (const QRectF &rect) const
 
QPolygonF mapToScene (const QRectF &rect) const
 
QRectF mapRectToItem (const QGraphicsItem *item, const QRectF &rect) const
 
QRectF mapRectToParent (const QRectF &rect) const
 
QRectF mapRectToScene (const QRectF &rect) const
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 
QPolygonF mapToParent (const QPolygonF &polygon) const
 
QPolygonF mapToScene (const QPolygonF &polygon) const
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const
 
QPainterPath mapToParent (const QPainterPath &path) const
 
QPainterPath mapToScene (const QPainterPath &path) const
 
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const
 
QPointF mapFromParent (const QPointF &point) const
 
QPointF mapFromScene (const QPointF &point) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const
 
QPolygonF mapFromParent (const QRectF &rect) const
 
QPolygonF mapFromScene (const QRectF &rect) const
 
QRectF mapRectFromItem (const QGraphicsItem *item, const QRectF &rect) const
 
QRectF mapRectFromParent (const QRectF &rect) const
 
QRectF mapRectFromScene (const QRectF &rect) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 
QPolygonF mapFromParent (const QPolygonF &polygon) const
 
QPolygonF mapFromScene (const QPolygonF &polygon) const
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const
 
QPainterPath mapFromParent (const QPainterPath &path) const
 
QPainterPath mapFromScene (const QPainterPath &path) const
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const
 
QPointF mapToParent (qreal x, qreal y) const
 
QPointF mapToScene (qreal x, qreal y) const
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const
 
QPointF mapFromParent (qreal x, qreal y) const
 
QPointF mapFromScene (qreal x, qreal y) const
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const
 
bool isAncestorOf (const QGraphicsItem *child) const
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const
 
bool isUnderMouse () const
 
QVariant data (int key) const
 
void setData (int key, const QVariant &value)
 
Qt::InputMethodHints inputMethodHints () const
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 

Protected Member Functions

bool sceneEvent (QEvent *event) override
 
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 
void contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
void focusInEvent (QFocusEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
void dragEnterEvent (QGraphicsSceneDragDropEvent *event) override
 
void dragLeaveEvent (QGraphicsSceneDragDropEvent *event) override
 
void dragMoveEvent (QGraphicsSceneDragDropEvent *event) override
 
void dropEvent (QGraphicsSceneDragDropEvent *event) override
 
void inputMethodEvent (QInputMethodEvent *event) override
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event) override
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 
QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 
bool supportsExtension (Extension extension) const override
 
void setExtension (Extension extension, const QVariant &variant) override
 
QVariant extension (const QVariant &variant) const override
 
- Protected Member Functions inherited from QGraphicsObject
 QGraphicsObject (QGraphicsItemPrivate &dd, QGraphicsItem *parent)
 
bool event (QEvent *ev) override
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QGraphicsItem
void updateMicroFocus ()
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent)
 
void addToIndex ()
 
void removeFromIndex ()
 
void prepareGeometryChange ()
 

Friends

class QGraphicsTextItemPrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Types inherited from QGraphicsItem
enum  Extension { UserExtension = 0x80000000 }
 
- Protected Slots inherited from QGraphicsObject
void updateMicroFocus ()
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Attributes inherited from QGraphicsItem
QScopedPointer< QGraphicsItemPrivated_ptr
 
- Properties inherited from QGraphicsObject
QGraphicsObjectparent
 the parent of the item More...
 
qreal opacity
 the opacity of the item More...
 
bool enabled
 whether the item is enabled or not More...
 
bool visible
 whether the item is visible or not More...
 
QPointF pos
 the position of the item More...
 
qreal x
 the x position of the item More...
 
qreal y
 the y position of the item More...
 
qreal z
 the z value of the item More...
 
qreal rotation
 the rotation of the item in degrees. More...
 
qreal scale
 the scale of the item. More...
 
QPointF transformOriginPoint
 the transformation origin More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Detailed Description

The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text.

Since
4.2

\inmodule QtWidgets

If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem instead.

To set the item's text, pass a QString to QGraphicsTextItem's constructor, or call setHtml()/setPlainText().

QGraphicsTextItem uses the text's formatted size and the associated font to provide a reasonable implementation of boundingRect(), shape(), and contains(). You can set the font by calling setFont().

It is possible to make the item editable by setting the Qt::TextEditorInteraction flag using setTextInteractionFlags().

The item's preferred text width can be set using setTextWidth() and obtained using textWidth().

Note
In order to align HTML text in the center, the item's text width must be set. Otherwise, you can call adjustSize() after setting the item's text.
QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events} by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}.
See also
QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, {Graphics View Framework}

Definition at line 857 of file qgraphicsitem.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 889 of file qgraphicsitem.h.

Constructor & Destructor Documentation

◆ QGraphicsTextItem() [1/2]

QGraphicsTextItem::QGraphicsTextItem ( QGraphicsItem parent = nullptr)
explicit

Constructs a QGraphicsTextItem. parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 9804 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ QGraphicsTextItem() [2/2]

QGraphicsTextItem::QGraphicsTextItem ( const QString text,
QGraphicsItem parent = nullptr 
)
explicit

Constructs a QGraphicsTextItem, using text as the default plain text. parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 9786 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ ~QGraphicsTextItem()

QGraphicsTextItem::~QGraphicsTextItem ( )

Destroys the QGraphicsTextItem.

Definition at line 9817 of file qgraphicsitem.cpp.

Member Function Documentation

◆ adjustSize()

void QGraphicsTextItem::adjustSize ( )

Adjusts the text item to a reasonable size.

Definition at line 10040 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ boundingRect()

QRectF QGraphicsTextItem::boundingRect ( ) const
overridevirtual

\reimp

Implements QGraphicsItem.

Definition at line 9919 of file qgraphicsitem.cpp.

Here is the caller graph for this function:

◆ contains()

bool QGraphicsTextItem::contains ( const QPointF point) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 9939 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contextMenuEvent()

void QGraphicsTextItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10200 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ defaultTextColor()

QColor QGraphicsTextItem::defaultTextColor ( ) const

Returns the default text color that is used for unformatted text.

Definition at line 9911 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ document()

QTextDocument * QGraphicsTextItem::document ( ) const

Returns the item's text document.

Definition at line 10058 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dragEnterEvent()

void QGraphicsTextItem::dragEnterEvent ( QGraphicsSceneDragDropEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10245 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ dragLeaveEvent()

void QGraphicsTextItem::dragLeaveEvent ( QGraphicsSceneDragDropEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10253 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ dragMoveEvent()

void QGraphicsTextItem::dragMoveEvent ( QGraphicsSceneDragDropEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10261 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ dropEvent()

void QGraphicsTextItem::dropEvent ( QGraphicsSceneDragDropEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10269 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ extension()

QVariant QGraphicsTextItem::extension ( const QVariant variant) const
overrideprotectedvirtual

Reimplemented from QGraphicsItem.

Definition at line 10350 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ focusInEvent()

void QGraphicsTextItem::focusInEvent ( QFocusEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in FocusItem.

Definition at line 10224 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ focusOutEvent()

void QGraphicsTextItem::focusOutEvent ( QFocusEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Reimplemented in FocusItem.

Definition at line 10236 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ font()

QFont QGraphicsTextItem::font ( ) const

Returns the item's font, which is used to render the text.

See also
setFont()

Definition at line 9877 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hoverEnterEvent()

void QGraphicsTextItem::hoverEnterEvent ( QGraphicsSceneHoverEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10285 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ hoverLeaveEvent()

void QGraphicsTextItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10301 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ hoverMoveEvent()

void QGraphicsTextItem::hoverMoveEvent ( QGraphicsSceneHoverEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10293 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ inputMethodEvent()

void QGraphicsTextItem::inputMethodEvent ( QInputMethodEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10277 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ inputMethodQuery()

QVariant QGraphicsTextItem::inputMethodQuery ( Qt::InputMethodQuery  query) const
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10309 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ isObscuredBy()

bool QGraphicsTextItem::isObscuredBy ( const QGraphicsItem item) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 9980 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ keyPressEvent()

void QGraphicsTextItem::keyPressEvent ( QKeyEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10208 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ keyReleaseEvent()

void QGraphicsTextItem::keyReleaseEvent ( QKeyEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10216 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ linkActivated

void QGraphicsTextItem::linkActivated ( const QString link)
signal

This signal is emitted when the user clicks on a link on a text item that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard. link is the link that was clicked.

See also
setTextInteractionFlags()
Here is the caller graph for this function:

◆ linkHovered

void QGraphicsTextItem::linkHovered ( const QString link)
signal

This signal is emitted when the user hovers over a link on a text item that enables Qt::LinksAccessibleByMouse. link is the link that was hovered over.

See also
setTextInteractionFlags()
Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void QGraphicsTextItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10182 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseMoveEvent()

void QGraphicsTextItem::mouseMoveEvent ( QGraphicsSceneMouseEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10143 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ mousePressEvent()

void QGraphicsTextItem::mousePressEvent ( QGraphicsSceneMouseEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10118 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ mouseReleaseEvent()

void QGraphicsTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10156 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ opaqueArea()

QPainterPath QGraphicsTextItem::opaqueArea ( ) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 9988 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ openExternalLinks()

bool QGraphicsTextItem::openExternalLinks ( ) const

Specifies whether QGraphicsTextItem should automatically open links using QDesktopServices::openUrl() instead of emitting the linkActivated signal.

The default value is false.

Definition at line 10542 of file qgraphicsitem.cpp.

◆ paint()

void QGraphicsTextItem::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget 
)
overridevirtual

\reimp

Implements QGraphicsItem.

Reimplemented in QGraphicsTextItem_task172231.

Definition at line 9947 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sceneEvent()

bool QGraphicsTextItem::sceneEvent ( QEvent event)
overrideprotectedvirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 10066 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setDefaultTextColor()

void QGraphicsTextItem::setDefaultTextColor ( const QColor col)

Sets the color for unformatted text to col.

Definition at line 9897 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setDocument()

void QGraphicsTextItem::setDocument ( QTextDocument document)

Sets the text document document on the item.

Definition at line 10049 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setExtension()

void QGraphicsTextItem::setExtension ( Extension  extension,
const QVariant variant 
)
overrideprotectedvirtual

Reimplemented from QGraphicsItem.

Definition at line 10341 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setFont()

void QGraphicsTextItem::setFont ( const QFont font)

Sets the font used to render the text item to font.

See also
font()

Definition at line 9889 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setHtml()

void QGraphicsTextItem::setHtml ( const QString text)

Sets the item's text to text, assuming that text is HTML formatted. If the item has keyboard input focus, this function will also call ensureVisible() to ensure that the text is visible in all viewports.

See also
toHtml(), hasFocus(), QGraphicsSimpleTextItem

Definition at line 9843 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setOpenExternalLinks()

void QGraphicsTextItem::setOpenExternalLinks ( bool  open)

Definition at line 10537 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setPlainText()

void QGraphicsTextItem::setPlainText ( const QString text)

Sets the item's text to text. If the item has keyboard input focus, this function will also call ensureVisible() to ensure that the text is visible in all viewports.

See also
toHtml(), hasFocus()

Definition at line 9867 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTabChangesFocus()

void QGraphicsTextItem::setTabChangesFocus ( bool  b)
Since
4.5

If b is true, the \uicontrol Tab key will cause the widget to change focus; otherwise, the tab key will insert a tab into the document.

In some occasions text edits should not allow the user to input tabulators or change indentation using the \uicontrol Tab key, as this breaks the focus chain. The default is false.

See also
tabChangesFocus(), ItemIsFocusable, textInteractionFlags()

Definition at line 10508 of file qgraphicsitem.cpp.

◆ setTextCursor()

void QGraphicsTextItem::setTextCursor ( const QTextCursor cursor)

Definition at line 10559 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ setTextInteractionFlags()

void QGraphicsTextItem::setTextInteractionFlags ( Qt::TextInteractionFlags  flags)

Sets the flags flags to specify how the text item should react to user input.

The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function also affects the ItemIsFocusable QGraphicsItem flag by setting it if flags is different from Qt::NoTextInteraction and clearing it otherwise.

By default, the text is read-only. To transform the item into an editor, set the Qt::TextEditable flag.

Definition at line 10474 of file qgraphicsitem.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTextWidth()

void QGraphicsTextItem::setTextWidth ( qreal  width)

Sets the preferred width for the item's text. If the actual text is wider than the specified width then it will be broken into multiple lines.

If width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.

The default value is -1.

Note that QGraphicsTextItem keeps a QTextDocument internally, which is used to calculate the text width.

See also
textWidth(), QTextDocument::setTextWidth()

Definition at line 10017 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ shape()

QPainterPath QGraphicsTextItem::shape ( ) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 9927 of file qgraphicsitem.cpp.

◆ supportsExtension()

bool QGraphicsTextItem::supportsExtension ( Extension  extension) const
overrideprotectedvirtual

Reimplemented from QGraphicsItem.

Definition at line 10332 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ tabChangesFocus()

bool QGraphicsTextItem::tabChangesFocus ( ) const
Since
4.5

Returns true if the \uicontrol Tab key will cause the widget to change focus; otherwise, false is returned.

By default, this behavior is disabled, and this function will return false.

See also
setTabChangesFocus()

Definition at line 10523 of file qgraphicsitem.cpp.

◆ textCursor()

QTextCursor QGraphicsTextItem::textCursor ( ) const

This property represents the visible text cursor in an editable text item.

By default, if the item's text has not been set, this property contains a null text cursor; otherwise it contains a text cursor placed at the start of the item's document.

Definition at line 10564 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ textInteractionFlags()

Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags ( ) const

Returns the current text interaction flags.

See also
setTextInteractionFlags()

Definition at line 10489 of file qgraphicsitem.cpp.

Here is the caller graph for this function:

◆ textWidth()

qreal QGraphicsTextItem::textWidth ( ) const

Returns the text width.

The width is calculated with the QTextDocument that QGraphicsTextItem keeps internally.

See also
setTextWidth(), QTextDocument::textWidth()

Definition at line 10030 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ toHtml()

QString QGraphicsTextItem::toHtml ( ) const

Returns the item's text converted to HTML, or an empty QString if no text has been set.

See also
setHtml()

Definition at line 9827 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ toPlainText()

QString QGraphicsTextItem::toPlainText ( ) const

Returns the item's text converted to plain text, or an empty QString if no text has been set.

See also
setPlainText()

Definition at line 9853 of file qgraphicsitem.cpp.

Here is the call graph for this function:

◆ type()

int QGraphicsTextItem::type ( ) const
overridevirtual

\reimp

Reimplemented from QGraphicsItem.

Definition at line 9996 of file qgraphicsitem.cpp.

Friends And Related Function Documentation

◆ QGraphicsTextItemPrivate

friend class QGraphicsTextItemPrivate
friend

Definition at line 945 of file qgraphicsitem.h.


The documentation for this class was generated from the following files: