Qt 4.8
Public Types | Signals | Public Functions | Protected Functions | Properties | 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:
QGraphicsObject QObject QGraphicsItem

Public Types

enum  { Type = 8 }
 
- Public Types inherited from QGraphicsItem
enum  { Type = 1, UserType = 65536 }
 
enum  CacheMode { NoCache, ItemCoordinateCache, DeviceCoordinateCache }
 This enum describes QGraphicsItem's cache modes. More...
 
enum  GraphicsItemChange {
  ItemPositionChange, ItemMatrixChange, ItemVisibleChange, 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
}
 This enum describes the state changes that are notified by QGraphicsItem::itemChange(). More...
 
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
}
 This enum describes different flags that you can set on an item to toggle different features in the item's behavior. More...
 
enum  PanelModality { NonModal, PanelModal, SceneModal }
 This enum specifies the behavior of a modal panel. More...
 

Signals

void linkActivated (const QString &)
 This signal is emitted when the user clicks on a link on a text item that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard. More...
 
void linkHovered (const QString &)
 This signal is emitted when the user hovers over a link on a text item that enables Qt::LinksAccessibleByMouse. More...
 
- Signals inherited from QGraphicsObject
void childrenChanged ()
 This signal gets emitted whenever the children list changes. More...
 
void enabledChanged ()
 This signal gets emitted whenever the item get's enabled or disabled. More...
 
void heightChanged ()
 
void opacityChanged ()
 This signal gets emitted whenever the opacity of the item changes. More...
 
void parentChanged ()
 This signal gets emitted whenever the parent of the item changes. More...
 
void rotationChanged ()
 This signal gets emitted whenever the roation of the item changes. More...
 
void scaleChanged ()
 This signal is emitted when the scale of the item changes. More...
 
void visibleChanged ()
 This signal gets emitted whenever the visibility of the item changes. More...
 
void widthChanged ()
 
void xChanged ()
 This signal gets emitted whenever the x position of the item changes. More...
 
void yChanged ()
 This signal gets emitted whenever the y position of the item changes. More...
 
void zChanged ()
 This signal gets emitted whenever the z value of the item changes. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

void adjustSize ()
 Adjusts the text item to a reasonable size. More...
 
QRectF boundingRect () const
 Reimplemented Function More...
 
bool contains (const QPointF &point) const
 Reimplemented Function More...
 
QColor defaultTextColor () const
 Returns the default text color that is used to for unformatted text. More...
 
QTextDocumentdocument () const
 Returns the item's text document. More...
 
QFont font () const
 Returns the item's font, which is used to render the text. More...
 
bool isObscuredBy (const QGraphicsItem *item) const
 Reimplemented Function More...
 
QPainterPath opaqueArea () const
 Reimplemented Function More...
 
bool openExternalLinks () const
 Specifies whether QGraphicsTextItem should automatically open links using QDesktopServices::openUrl() instead of emitting the linkActivated signal. More...
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 Reimplemented Function More...
 
 QGraphicsTextItem (QGraphicsItem *parent=0)
 Constructs a QGraphicsTextItem. More...
 
 QGraphicsTextItem (const QString &text, QGraphicsItem *parent=0)
 Constructs a QGraphicsTextItem, using text as the default plain text. More...
 
void setDefaultTextColor (const QColor &c)
 Sets the color for unformatted text to col. More...
 
void setDocument (QTextDocument *document)
 Sets the text document document on the item. More...
 
void setFont (const QFont &font)
 Sets the font used to render the text item to font. More...
 
void setHtml (const QString &html)
 Sets the item's text to text, assuming that text is HTML formatted. More...
 
void setOpenExternalLinks (bool open)
 
void setPlainText (const QString &text)
 Sets the item's text to text. More...
 
void setTabChangesFocus (bool b)
 If b is true, the Tab key will cause the widget to change focus; otherwise, the tab key will insert a tab into the document. More...
 
void setTextCursor (const QTextCursor &cursor)
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 Sets the flags flags to specify how the text item should react to user input. More...
 
void setTextWidth (qreal width)
 Sets the preferred width for the item's text. More...
 
QPainterPath shape () const
 Reimplemented Function More...
 
bool tabChangesFocus () const
 Returns true if the Tab key will cause the widget to change focus; otherwise, false is returned. More...
 
QTextCursor textCursor () const
 This property represents the visible text cursor in an editable text item. More...
 
Qt::TextInteractionFlags textInteractionFlags () const
 Returns the current text interaction flags. More...
 
qreal textWidth () const
 Returns the text width. More...
 
QString toHtml () const
 Returns the item's text converted to HTML, or an empty QString if no text has been set. More...
 
QString toPlainText () const
 Returns the item's text converted to plain text, or an empty QString if no text has been set. More...
 
int type () const
 Reimplemented Function More...
 
 ~QGraphicsTextItem ()
 Destroys the QGraphicsTextItem. More...
 
- Public Functions inherited from QGraphicsObject
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the graphics object to the given gesture with specific flags. More...
 
 QGraphicsObject (QGraphicsItem *parent=0)
 Constructs a QGraphicsObject with parent. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the graphics object from the given gesture. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QGraphicsItem
bool acceptDrops () const
 Returns true if this item can accept drag and drop events; otherwise, returns false. More...
 
Qt::MouseButtons acceptedMouseButtons () const
 Returns the mouse buttons that this item accepts mouse events for. More...
 
bool acceptHoverEvents () const
 Returns true if an item accepts hover events (QGraphicsSceneHoverEvent); otherwise, returns false. More...
 
bool acceptsHoverEvents () const
 Call acceptHoverEvents() instead. More...
 
bool acceptTouchEvents () const
 Returns true if an item accepts touch events; otherwise, returns false. More...
 
virtual void advance (int phase)
 This virtual function is called twice for all items by the QGraphicsScene::advance() slot. More...
 
QRegion boundingRegion (const QTransform &itemToDeviceTransform) const
 Returns the bounding region for this item. More...
 
qreal boundingRegionGranularity () const
 Returns the item's bounding region granularity; a value between and including 0 and 1. More...
 
CacheMode cacheMode () const
 Returns the cache mode for this item. More...
 
QList< QGraphicsItem * > childItems () const
 Returns a list of this item's children. More...
 
QList< QGraphicsItem * > children () const
 Use childItems() instead. More...
 
QRectF childrenBoundingRect () const
 Returns the bounding rect of this item's descendants (i.e., its children, their children, etc.) in local coordinates. More...
 
void clearFocus ()
 Takes keyboard input focus from the item. More...
 
QPainterPath clipPath () const
 Returns this item's clip path, or an empty QPainterPath if this item is not clipped. More...
 
virtual bool collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with other; otherwise returns false. More...
 
virtual bool collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns true if this item collides with path. More...
 
QList< QGraphicsItem * > collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const
 Returns a list of all items that collide with this item. More...
 
QGraphicsItemcommonAncestorItem (const QGraphicsItem *other) const
 Returns the closest common ancestor item of this item and other, or 0 if either other is 0, or there is no common ancestor. More...
 
QCursor cursor () const
 Returns the current cursor shape for the item. More...
 
QVariant data (int key) const
 Returns this item's custom data for the key key as a QVariant. More...
 
QTransform deviceTransform (const QTransform &viewportTransform) const
 Returns this item's device transformation matrix, using viewportTransform to map from scene to device coordinates. More...
 
qreal effectiveOpacity () const
 Returns this item's effective opacity, which is between 0. More...
 
void ensureVisible (const QRectF &rect=QRectF(), int xmargin=50, int ymargin=50)
 If this item is part of a scene that is viewed by a QGraphicsView, this convenience function will attempt to scroll the view to ensure that rect is visible inside the view's viewport. More...
 
void ensureVisible (qreal x, qreal y, qreal w, qreal h, int xmargin=50, int ymargin=50)
 This convenience function is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin): More...
 
bool filtersChildEvents () const
 Returns true if this item filters child events (i. More...
 
GraphicsItemFlags flags () const
 Returns this item's flags. More...
 
QGraphicsItemfocusItem () const
 If this item, a child or descendant of this item currently has input focus, this function will return a pointer to that item. More...
 
QGraphicsItemfocusProxy () const
 Returns this item's focus proxy, or 0 if this item has no focus proxy. More...
 
QGraphicsItemfocusScopeItem () const
 Returns this item's focus scope item. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
QGraphicsEffectgraphicsEffect () const
 Returns a pointer to this item's effect if it has one; otherwise 0. More...
 
QGraphicsItemGroupgroup () const
 Returns a pointer to this item's item group, or 0 if this item is not member of a group. More...
 
bool handlesChildEvents () const
 Returns true if this item handles child events (i. More...
 
bool hasCursor () const
 Returns true if this item has a cursor set; otherwise, false is returned. More...
 
bool hasFocus () const
 Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise, returns false. More...
 
void hide ()
 Hides the item. More...
 
Qt::InputMethodHints inputMethodHints () const
 Returns the current input method hints of this item. More...
 
void installSceneEventFilter (QGraphicsItem *filterItem)
 Installs an event filter for this item on filterItem, causing all events for this item to first pass through filterItem's sceneEventFilter() function. More...
 
bool isActive () const
 Returns true if this item is active; otherwise returns false. More...
 
bool isAncestorOf (const QGraphicsItem *child) const
 Returns true if this item is an ancestor of child (i.e., if this item is child's parent, or one of child's parent's ancestors). More...
 
bool isBlockedByModalPanel (QGraphicsItem **blockingPanel=0) const
 Returns true if this item is blocked by a modal panel, false otherwise. More...
 
bool isClipped () const
 Returns true if this item is clipped. More...
 
bool isEnabled () const
 Returns true if the item is enabled; otherwise, false is returned. More...
 
bool isObscured () const
 Returns true if this item's bounding rect is completely obscured by the opaque shape of any of colliding items above it (i.e., with a higher Z value than this item). More...
 
bool isObscured (const QRectF &rect) const
 Returns true if rect is completely obscured by the opaque shape of any of colliding items above it (i. More...
 
bool isObscured (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling isObscured(QRectF(x, y, w, h)). More...
 
bool isPanel () const
 Returns true if the item is a panel; otherwise returns false. More...
 
bool isSelected () const
 Returns true if this item is selected; otherwise, false is returned. More...
 
bool isUnderMouse () const
 Returns true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned. More...
 
bool isVisible () const
 Returns true if the item is visible; otherwise, false is returned. More...
 
bool isVisibleTo (const QGraphicsItem *parent) const
 Returns true if the item is visible to parent; otherwise, false is returned. More...
 
bool isWidget () const
 Returns true if this item is a widget (i. More...
 
bool isWindow () const
 Returns true if the item is a QGraphicsWidget window, otherwise returns false. More...
 
QTransform itemTransform (const QGraphicsItem *other, bool *ok=0) const
 Returns a QTransform that maps coordinates from this item to other. More...
 
QPointF mapFromItem (const QGraphicsItem *item, const QPointF &point) const
 Maps the point point, which is in item's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in item's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in item's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapFromItem(item, QPointF(x, y)). More...
 
QPolygonF mapFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapFromParent (const QPointF &point) const
 Maps the point point, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromParent (const QPainterPath &path) const
 Maps the path path, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromParent(QPointF(x, y)). More...
 
QPolygonF mapFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromItem(QRectF(x, y, w, h)). More...
 
QPointF mapFromScene (const QPointF &point) const
 Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapFromScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapFromScene (const QPainterPath &path) const
 Maps the path path, which is in this item's scene's coordinate system, to this item's coordinate system, and returns the mapped path. More...
 
QPointF mapFromScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapFromScene(QPointF(x, y)). More...
 
QPolygonF mapFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapFromScene(QRectF(x, y, w, h)). More...
 
QRectF mapRectFromItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in item's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectFromParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's parent's coordinate system, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectFromScene (const QRectF &rect) const
 Maps the rectangle rect, which is in scene coordinates, to this item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectFromScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectFromScene(QRectF(x, y, w, h)). More...
 
QRectF mapRectToItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QRectF mapRectToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToParent(QRectF(x, y, w, h)). More...
 
QRectF mapRectToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene coordinate system, and returns the mapped rectangle as a new rectangle (i. More...
 
QRectF mapRectToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapRectToScene(QRectF(x, y, w, h)). More...
 
QPointF mapToItem (const QGraphicsItem *item, const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to item's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to item's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToItem (const QGraphicsItem *item, const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToItem (const QGraphicsItem *item, const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to item's coordinate system, and returns the mapped path. More...
 
QPointF mapToItem (const QGraphicsItem *item, qreal x, qreal y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This convenience function is equivalent to calling mapToItem(item, QPointF(x, y)). More...
 
QPolygonF mapToItem (const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
 
QPointF mapToParent (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToParent (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToParent (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToParent (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path. More...
 
QPointF mapToParent (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToParent(QPointF(x, y)). More...
 
QPolygonF mapToParent (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)). More...
 
QPointF mapToScene (const QPointF &point) const
 Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate. More...
 
QPolygonF mapToScene (const QRectF &rect) const
 Maps the rectangle rect, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped rectangle as a polygon. More...
 
QPolygonF mapToScene (const QPolygonF &polygon) const
 Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon. More...
 
QPainterPath mapToScene (const QPainterPath &path) const
 Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path. More...
 
QPointF mapToScene (qreal x, qreal y) const
 This convenience function is equivalent to calling mapToScene(QPointF(x, y)). More...
 
QPolygonF mapToScene (qreal x, qreal y, qreal w, qreal h) const
 This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)). More...
 
QMatrix matrix () const
 Returns the item's affine transformation matrix. More...
 
void moveBy (qreal dx, qreal dy)
 Moves the item by dx points horizontally, and dy point vertically. More...
 
qreal opacity () const
 Returns this item's local opacity, which is between 0. More...
 
QGraphicsItempanel () const
 Returns the item's panel, or 0 if this item does not have a panel. More...
 
PanelModality panelModality () const
 Returns the modality for this item. More...
 
QGraphicsItemparentItem () const
 Returns a pointer to this item's parent item. More...
 
QGraphicsObjectparentObject () const
 Returns a pointer to the item's parent, cast to a QGraphicsObject. More...
 
QGraphicsWidgetparentWidget () const
 Returns a pointer to the item's parent widget. More...
 
QPointF pos () const
 Returns the position of the item in parent coordinates. More...
 
 QGraphicsItem (QGraphicsItem *parent=0)
 Constructs a QGraphicsItem with the given parent item. More...
 
void removeSceneEventFilter (QGraphicsItem *filterItem)
 Removes an event filter on this item from filterItem. More...
 
void resetMatrix ()
 Use resetTransform() instead. More...
 
void resetTransform ()
 Resets this item's transformation matrix to the identity matrix or all the transformation properties to their default values. More...
 
void rotate (qreal angle)
 Use. More...
 
qreal rotation () const
 Returns the clockwise rotation, in degrees, around the Z axis. More...
 
void scale (qreal sx, qreal sy)
 Use. More...
 
qreal scale () const
 Returns the scale factor of the item. More...
 
QGraphicsScenescene () const
 Returns the current scene for the item, or 0 if the item is not stored in a scene. More...
 
QRectF sceneBoundingRect () const
 Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(). More...
 
QMatrix sceneMatrix () const
 Use sceneTransform() instead. More...
 
QPointF scenePos () const
 Returns the item's position in scene coordinates. More...
 
QTransform sceneTransform () const
 Returns this item's scene transformation matrix. More...
 
void scroll (qreal dx, qreal dy, const QRectF &rect=QRectF())
 Scrolls the contents of rect by dx, dy. More...
 
void setAcceptDrops (bool on)
 If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events. More...
 
void setAcceptedMouseButtons (Qt::MouseButtons buttons)
 Sets the mouse buttons that this item accepts mouse events for. More...
 
void setAcceptHoverEvents (bool enabled)
 If enabled is true, this item will accept hover events; otherwise, it will ignore them. More...
 
void setAcceptsHoverEvents (bool enabled)
 Use setAcceptHoverEvents(enabled) instead. More...
 
void setAcceptTouchEvents (bool enabled)
 If enabled is true, this item will accept touch events; otherwise, it will ignore them. More...
 
void setActive (bool active)
 If active is true, and the scene is active, this item's panel will be activated. More...
 
void setBoundingRegionGranularity (qreal granularity)
 Sets the bounding region granularity to granularity; a value between and including 0 and 1. More...
 
void setCacheMode (CacheMode mode, const QSize &cacheSize=QSize())
 Sets the item's cache mode to mode. More...
 
void setCursor (const QCursor &cursor)
 Sets the current cursor shape for the item to cursor. More...
 
void setData (int key, const QVariant &value)
 Sets this item's custom data for the key key to value. More...
 
void setEnabled (bool enabled)
 If enabled is true, the item is enabled; otherwise, it is disabled. More...
 
void setFiltersChildEvents (bool enabled)
 If enabled is true, this item is set to filter all events for all its children (i. More...
 
void setFlag (GraphicsItemFlag flag, bool enabled=true)
 If enabled is true, the item flag flag is enabled; otherwise, it is disabled. More...
 
void setFlags (GraphicsItemFlags flags)
 Sets the item flags to flags. More...
 
void setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason)
 Gives keyboard input focus to this item. More...
 
void setFocusProxy (QGraphicsItem *item)
 Sets the item's focus proxy to item. More...
 
void setGraphicsEffect (QGraphicsEffect *effect)
 Sets effect as the item's effect. More...
 
void setGroup (QGraphicsItemGroup *group)
 Adds this item to the item group group. More...
 
void setHandlesChildEvents (bool enabled)
 If enabled is true, this item is set to handle all events for all its children (i. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 Sets the current input method hints of this item to hints. More...
 
void setMatrix (const QMatrix &matrix, bool combine=false)
 Sets the item's affine transformation matrix. More...
 
void setOpacity (qreal opacity)
 Sets this item's local opacity, between 0. More...
 
void setPanelModality (PanelModality panelModality)
 Sets the modality for this item to panelModality. More...
 
void setParentItem (QGraphicsItem *parent)
 Sets this item's parent item to newParent. More...
 
void setPos (const QPointF &pos)
 Sets the position of the item to pos, which is in parent coordinates. More...
 
void setPos (qreal x, qreal y)
 This convenience function is equivalent to calling setPos(QPointF(x, y)). More...
 
void setRotation (qreal angle)
 Sets the clockwise rotation angle, in degrees, around the Z axis. More...
 
void setScale (qreal scale)
 Sets the scale factor of the item. More...
 
void setSelected (bool selected)
 If selected is true and this item is selectable, this item is selected; otherwise, it is unselected. More...
 
void setToolTip (const QString &toolTip)
 Sets the item's tool tip to toolTip. More...
 
void setTransform (const QTransform &matrix, bool combine=false)
 Sets the item's current transformation matrix to matrix. More...
 
void setTransformations (const QList< QGraphicsTransform *> &transformations)
 Sets a list of graphics transformations (QGraphicsTransform) that currently apply to this item. More...
 
void setTransformOriginPoint (const QPointF &origin)
 Sets the origin point for the transformation in item coordinates. More...
 
void setTransformOriginPoint (qreal ax, qreal ay)
 Sets the origin point for the transformation in item coordinates. More...
 
void setVisible (bool visible)
 If visible is true, the item is made visible. More...
 
void setX (qreal x)
 Set's the x coordinate of the item's position. More...
 
void setY (qreal y)
 Set's the y coordinate of the item's position. More...
 
void setZValue (qreal z)
 Sets the Z-value of the item to z. More...
 
void shear (qreal sh, qreal sv)
 Use. More...
 
void show ()
 Shows the item. More...
 
void stackBefore (const QGraphicsItem *sibling)
 Stacks this item before sibling, which must be a sibling item (i. More...
 
QGraphicsObjecttoGraphicsObject ()
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
const QGraphicsObjecttoGraphicsObject () const
 Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object, 0 otherwise. More...
 
QString toolTip () const
 Returns the item's tool tip, or an empty QString if no tool tip has been set. More...
 
QGraphicsItemtopLevelItem () const
 Returns this item's top-level item. More...
 
QGraphicsWidgettopLevelWidget () const
 Returns a pointer to the item's top level widget (i. More...
 
QTransform transform () const
 Returns this item's transformation matrix. More...
 
QList< QGraphicsTransform * > transformations () const
 Returns a list of graphics transforms that currently apply to this item. More...
 
QPointF transformOriginPoint () const
 Returns the origin point for the transformation in item coordinates. More...
 
void translate (qreal dx, qreal dy)
 Use setPos() or setTransformOriginPoint() instead. More...
 
void ungrabKeyboard ()
 Releases the keyboard grab. More...
 
void ungrabMouse ()
 Releases the mouse grab. More...
 
void unsetCursor ()
 Clears the cursor from this item. More...
 
void update (const QRectF &rect=QRectF())
 Schedules a redraw of the area covered by rect in this item. More...
 
void update (qreal x, qreal y, qreal width, qreal height)
 This convenience function is equivalent to calling update(QRectF(x, y, width, height)). More...
 
QGraphicsWidgetwindow () const
 Returns the item's window, or 0 if this item does not have a window. More...
 
qreal x () const
 This convenience function is equivalent to calling pos(). More...
 
qreal y () const
 This convenience function is equivalent to calling pos(). More...
 
qreal zValue () const
 Returns the Z-value of the item. More...
 
virtual ~QGraphicsItem ()
 Destroys the QGraphicsItem and all its children. More...
 

Protected Functions

void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
 Reimplemented Function More...
 
void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dragMoveEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
void dropEvent (QGraphicsSceneDragDropEvent *event)
 Reimplemented Function More...
 
QVariant extension (const QVariant &variant) const
 
void focusInEvent (QFocusEvent *event)
 Reimplemented Function More...
 
void focusOutEvent (QFocusEvent *event)
 Reimplemented Function More...
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 Reimplemented Function More...
 
void inputMethodEvent (QInputMethodEvent *event)
 Reimplemented Function More...
 
QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 Reimplemented Function More...
 
void keyPressEvent (QKeyEvent *event)
 Reimplemented Function More...
 
void keyReleaseEvent (QKeyEvent *event)
 Reimplemented Function More...
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 Reimplemented Function More...
 
bool sceneEvent (QEvent *event)
 Reimplemented Function More...
 
void setExtension (Extension extension, const QVariant &variant)
 
bool supportsExtension (Extension extension) const
 
- Protected Functions inherited from QGraphicsObject
 QGraphicsObject (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QGraphicsItem
void addToIndex ()
 Adds this item to the scene's index. More...
 
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value)
 This virtual function is called by QGraphicsItem to notify custom items that some part of the item's state changes. More...
 
void prepareGeometryChange ()
 Prepares the item for a geometry change. More...
 
 QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
 
void removeFromIndex ()
 Removes this item from the scene's index. More...
 
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 Filters events for the item watched. More...
 
void updateMicroFocus ()
 Updates the item's micro focus. More...
 
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
 This event handler, for event event, can be reimplemented to receive wheel events for this item. More...
 

Properties

QGraphicsTextItemPrivatedd
 

Friends

class QGraphicsTextItemPrivate
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Types inherited from QGraphicsItem
enum  Extension { UserExtension = 0x80000000 }
 Note: This is provided as a hook to avoid future problems related to adding virtual functions. More...
 
- Protected Slots inherited from QGraphicsObject
void updateMicroFocus ()
 Updates the item's micro focus. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QGraphicsItem
QScopedPointer< QGraphicsItemPrivated_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

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

Since
4.2

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.
graphicsview-textitem.png
Note
QGraphicsTextItem accepts hover events by default. You can change this with QGraphicsItem::setAcceptHoverEvents().
See also
QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, {Graphics View Framework}

Definition at line 960 of file qgraphicsitem.h.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 1002 of file qgraphicsitem.h.

Constructors and Destructors

◆ QGraphicsTextItem() [1/2]

QGraphicsTextItem::QGraphicsTextItem ( QGraphicsItem parent = 0)

Constructs a QGraphicsTextItem.

parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 10462 of file qgraphicsitem.cpp.

10469 {
10470  dd->qq = this;
10471  setAcceptDrops(true);
10472  setAcceptHoverEvents(true);
10474 }
QGraphicsObject(QGraphicsItem *parent=0)
Constructs a QGraphicsObject with parent.
void setAcceptDrops(bool on)
If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and ...
void setAcceptHoverEvents(bool enabled)
If enabled is true, this item will accept hover events; otherwise, it will ignore them...
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
QGraphicsTextItemPrivate * dd
QGraphicsTextItem * qq
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.

◆ QGraphicsTextItem() [2/2]

QGraphicsTextItem::QGraphicsTextItem ( const QString text,
QGraphicsItem parent = 0 
)

Constructs a QGraphicsTextItem, using text as the default plain text.

parent is passed to QGraphicsItem's constructor.

See also
QGraphicsScene::addItem()

Definition at line 10440 of file qgraphicsitem.cpp.

10447 {
10448  dd->qq = this;
10449  if (!text.isEmpty())
10450  setPlainText(text);
10451  setAcceptDrops(true);
10452  setAcceptHoverEvents(true);
10454 }
QGraphicsObject(QGraphicsItem *parent=0)
Constructs a QGraphicsObject with parent.
void setAcceptDrops(bool on)
If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and ...
void setFlags(GraphicsItemFlags flags)
Sets the item flags to flags.
void setPlainText(const QString &text)
Sets the item&#39;s text to text.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setAcceptHoverEvents(bool enabled)
If enabled is true, this item will accept hover events; otherwise, it will ignore them...
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
QGraphicsTextItemPrivate * dd
QGraphicsTextItem * qq

◆ ~QGraphicsTextItem()

QGraphicsTextItem::~QGraphicsTextItem ( )

Destroys the QGraphicsTextItem.

Definition at line 10479 of file qgraphicsitem.cpp.

10480 {
10481  delete dd;
10482 }
QGraphicsTextItemPrivate * dd

Functions

◆ adjustSize()

void QGraphicsTextItem::adjustSize ( )

Adjusts the text item to a reasonable size.

Definition at line 10702 of file qgraphicsitem.cpp.

10703 {
10704  if (dd->control)
10705  dd->control->adjustSize();
10706 }
QGraphicsTextItemPrivate * dd

◆ boundingRect()

QRectF QGraphicsTextItem::boundingRect ( ) const
virtual

◆ contains()

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

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10601 of file qgraphicsitem.cpp.

10602 {
10603  return dd->boundingRect.contains(point);
10604 }
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
QGraphicsTextItemPrivate * dd

◆ contextMenuEvent()

void QGraphicsTextItem::contextMenuEvent ( QGraphicsSceneContextMenuEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10866 of file qgraphicsitem.cpp.

10867 {
10868  dd->sendControlEvent(event);
10869 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ defaultTextColor()

QColor QGraphicsTextItem::defaultTextColor ( ) const

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

Definition at line 10573 of file qgraphicsitem.cpp.

10574 {
10575  return dd->textControl()->palette().color(QPalette::Text);
10576 }
QTextControl * textControl() const
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QPalette palette() const
QGraphicsTextItemPrivate * dd

◆ document()

QTextDocument * QGraphicsTextItem::document ( ) const

Returns the item's text document.

Definition at line 10720 of file qgraphicsitem.cpp.

10721 {
10722  return dd->textControl()->document();
10723 }
QTextControl * textControl() const
QTextDocument * document() const
QGraphicsTextItemPrivate * dd

◆ dragEnterEvent()

void QGraphicsTextItem::dragEnterEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10911 of file qgraphicsitem.cpp.

10912 {
10913  dd->sendControlEvent(event);
10914 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ dragLeaveEvent()

void QGraphicsTextItem::dragLeaveEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10919 of file qgraphicsitem.cpp.

10920 {
10921  dd->sendControlEvent(event);
10922 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ dragMoveEvent()

void QGraphicsTextItem::dragMoveEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10927 of file qgraphicsitem.cpp.

10928 {
10929  dd->sendControlEvent(event);
10930 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ dropEvent()

void QGraphicsTextItem::dropEvent ( QGraphicsSceneDragDropEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10935 of file qgraphicsitem.cpp.

10936 {
10937  dd->sendControlEvent(event);
10938 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ extension()

QVariant QGraphicsTextItem::extension ( const QVariant variant) const
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 11012 of file qgraphicsitem.cpp.

11013 {
11014  Q_UNUSED(variant);
11015  return QVariant();
11016 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ focusInEvent()

void QGraphicsTextItem::focusInEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10890 of file qgraphicsitem.cpp.

10891 {
10892  dd->sendControlEvent(event);
10893  if (event->reason() == Qt::MouseFocusReason) {
10894  dd->clickCausedFocus = 1;
10895  }
10896  update();
10897 }
void sendControlEvent(QEvent *e)
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
Qt::FocusReason reason()
Definition: qevent.cpp:1197
QGraphicsTextItemPrivate * dd

◆ focusOutEvent()

void QGraphicsTextItem::focusOutEvent ( QFocusEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10902 of file qgraphicsitem.cpp.

10903 {
10904  dd->sendControlEvent(event);
10905  update();
10906 }
void sendControlEvent(QEvent *e)
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
QGraphicsTextItemPrivate * dd

◆ font()

QFont QGraphicsTextItem::font ( ) const

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

See also
setFont()

Definition at line 10539 of file qgraphicsitem.cpp.

Referenced by QGraphicsSimpleTextItemPrivate::updateBoundingRect().

10540 {
10541  if (!dd->control)
10542  return QFont();
10543  return dd->control->document()->defaultFont();
10544 }
QFont defaultFont
the default font used to display the document&#39;s text
QTextDocument * document() const
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QGraphicsTextItemPrivate * dd

◆ hoverEnterEvent()

void QGraphicsTextItem::hoverEnterEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10951 of file qgraphicsitem.cpp.

10952 {
10953  dd->sendControlEvent(event);
10954 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ hoverLeaveEvent()

void QGraphicsTextItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10967 of file qgraphicsitem.cpp.

10968 {
10969  dd->sendControlEvent(event);
10970 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ hoverMoveEvent()

void QGraphicsTextItem::hoverMoveEvent ( QGraphicsSceneHoverEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10959 of file qgraphicsitem.cpp.

10960 {
10961  dd->sendControlEvent(event);
10962 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ inputMethodEvent()

void QGraphicsTextItem::inputMethodEvent ( QInputMethodEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10943 of file qgraphicsitem.cpp.

10944 {
10945  dd->sendControlEvent(event);
10946 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ inputMethodQuery()

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

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10975 of file qgraphicsitem.cpp.

10976 {
10977  QVariant v;
10978  if (dd->control)
10979  v = dd->control->inputMethodQuery(query);
10980  if (v.type() == QVariant::RectF)
10981  v = v.toRectF().translated(-dd->controlOffset());
10982  else if (v.type() == QVariant::PointF)
10983  v = v.toPointF() - dd->controlOffset();
10984  else if (v.type() == QVariant::Rect)
10985  v = v.toRect().translated(-dd->controlOffset().toPoint());
10986  else if (v.type() == QVariant::Point)
10987  v = v.toPoint() - dd->controlOffset().toPoint();
10988  return v;
10989 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
Definition: qvariant.cpp:2509
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:328
QRectF toRectF() const
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invali...
Definition: qvariant.cpp:2463
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
Definition: qvariant.cpp:2416
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
Definition: qrect.h:740
QGraphicsTextItemPrivate * dd
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Definition: qvariant.cpp:2400

◆ isObscuredBy()

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

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10642 of file qgraphicsitem.cpp.

10643 {
10644  return QGraphicsItem::isObscuredBy(item);
10645 }
virtual bool isObscuredBy(const QGraphicsItem *item) const
Returns true if this item&#39;s bounding rect is completely obscured by the opaque shape of item...

◆ keyPressEvent()

void QGraphicsTextItem::keyPressEvent ( QKeyEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10874 of file qgraphicsitem.cpp.

10875 {
10876  dd->sendControlEvent(event);
10877 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ keyReleaseEvent()

void QGraphicsTextItem::keyReleaseEvent ( QKeyEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10882 of file qgraphicsitem.cpp.

10883 {
10884  dd->sendControlEvent(event);
10885 }
void sendControlEvent(QEvent *e)
QGraphicsTextItemPrivate * dd

◆ linkActivated

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()

Referenced by QGraphicsTextItemPrivate::textControl().

◆ linkHovered

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()

Referenced by QGraphicsTextItemPrivate::textControl().

◆ mouseDoubleClickEvent()

void QGraphicsTextItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10848 of file qgraphicsitem.cpp.

10849 {
10850  if (dd->useDefaultImpl) {
10852  return;
10853  }
10854 
10855  if (!hasFocus()) {
10857  return;
10858  }
10859 
10860  dd->sendControlEvent(event);
10861 }
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
void sendControlEvent(QEvent *e)
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
QGraphicsTextItemPrivate * dd

◆ mouseMoveEvent()

void QGraphicsTextItem::mouseMoveEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10809 of file qgraphicsitem.cpp.

10810 {
10811  if (dd->useDefaultImpl) {
10813  return;
10814  }
10815 
10816  dd->sendControlEvent(event);
10817 }
void sendControlEvent(QEvent *e)
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
QGraphicsTextItemPrivate * dd

◆ mousePressEvent()

void QGraphicsTextItem::mousePressEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10784 of file qgraphicsitem.cpp.

10785 {
10787  && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) {
10788  // User left-pressed on edge of selectable/movable item, use
10789  // base impl.
10790  dd->useDefaultImpl = true;
10791  } else if (event->buttons() == event->button()
10793  // User pressed first button on non-interactive item.
10794  dd->useDefaultImpl = true;
10795  }
10796  if (dd->useDefaultImpl) {
10798  if (!event->isAccepted())
10799  dd->useDefaultImpl = false;
10800  return;
10801  }
10802 
10803  dd->sendControlEvent(event);
10804 }
void sendControlEvent(QEvent *e)
QScopedPointer< QGraphicsItemPrivate > d_ptr
Qt::TextInteractionFlags textInteractionFlags
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *)
bool isAccepted() const
Definition: qcoreevent.h:307
GraphicsItemFlags flags() const
Returns this item&#39;s flags.
QGraphicsTextItemPrivate * dd
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...

◆ mouseReleaseEvent()

void QGraphicsTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10822 of file qgraphicsitem.cpp.

10823 {
10824  if (dd->useDefaultImpl) {
10827  && !event->buttons()) {
10828  // User released last button on non-interactive item.
10829  dd->useDefaultImpl = false;
10830  } else if ((event->buttons() & Qt::LeftButton) == 0) {
10831  // User released the left button on an interactive item.
10832  dd->useDefaultImpl = false;
10833  }
10834  return;
10835  }
10836 
10837  QWidget *widget = event->widget();
10838  if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) {
10840  }
10841  dd->clickCausedFocus = 0;
10842  dd->sendControlEvent(event);
10843 }
void sendControlEvent(QEvent *e)
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
Qt::TextInteractionFlags textInteractionFlags
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
Definition: qwidget_p.h:669
QPointF pos() const
Returns the mouse cursor position in item coordinates.
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QRectF boundingRect() const
Reimplemented Function
QGraphicsTextItemPrivate * dd
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...

◆ opaqueArea()

QPainterPath QGraphicsTextItem::opaqueArea ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10650 of file qgraphicsitem.cpp.

10651 {
10652  return QGraphicsItem::opaqueArea();
10653 }
virtual QPainterPath opaqueArea() const
This virtual function returns a shape representing the area where this item is opaque.

◆ 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 11222 of file qgraphicsitem.cpp.

11223 {
11224  if (!dd->control)
11225  return false;
11226  return dd->control->openExternalLinks();
11227 }
bool openExternalLinks
QGraphicsTextItemPrivate * dd

◆ paint()

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

Reimplemented Function

Implements QGraphicsItem.

Definition at line 10609 of file qgraphicsitem.cpp.

10611 {
10612  Q_UNUSED(widget);
10613  if (dd->control) {
10614  painter->save();
10615  QRectF r = option->exposedRect;
10616  painter->translate(-dd->controlOffset());
10617  r.translate(dd->controlOffset());
10618 
10619  QTextDocument *doc = dd->control->document();
10621 
10622  // the layout might need to expand the root frame to
10623  // the viewport if NoWrap is set
10624  if (layout)
10625  layout->setViewport(dd->boundingRect);
10626 
10627  dd->control->drawContents(painter, r);
10628 
10629  if (layout)
10630  layout->setViewport(QRect());
10631 
10632  painter->restore();
10633  }
10634 
10636  qt_graphicsItem_highlightSelected(this, painter, option);
10637 }
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
const char * layout
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
Definition: qrect.h:716
QTextDocument * document() const
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void drawContents(QPainter *painter, const QRectF &rect=QRectF(), QWidget *widget=0)
void setViewport(const QRectF &viewport)
QRectF exposedRect
the exposed rectangle, in item coordinates
Definition: qstyleoption.h:873
QGraphicsTextItemPrivate * dd
static void qt_graphicsItem_highlightSelected(QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
Highlights item as selected.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ sceneEvent()

bool QGraphicsTextItem::sceneEvent ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10728 of file qgraphicsitem.cpp.

10729 {
10730  QEvent::Type t = event->type();
10731  if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) {
10732  int k = ((QKeyEvent *)event)->key();
10733  if (k == Qt::Key_Tab || k == Qt::Key_Backtab) {
10734  dd->sendControlEvent(event);
10735  return true;
10736  }
10737  }
10738  bool result = QGraphicsItem::sceneEvent(event);
10739 
10740  // Ensure input context is updated.
10741  switch (event->type()) {
10742  case QEvent::ContextMenu:
10743  case QEvent::FocusIn:
10744  case QEvent::FocusOut:
10756  case QEvent::KeyPress:
10757  case QEvent::KeyRelease:
10758  // Reset the focus widget's input context, regardless
10759  // of how this item gained or lost focus.
10760  if (QWidget *fw = qApp->focusWidget()) {
10761 #ifndef QT_NO_IM
10762  if (QInputContext *qic = fw->inputContext()) {
10763  if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut)
10764  qic->reset();
10765  else
10766  qic->update();
10767  }
10768 #endif //QT_NO_IM
10769  }
10770  break;
10772  dd->sendControlEvent(event);
10773  return true;
10774  default:
10775  break;
10776  }
10777 
10778  return result;
10779 }
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual bool sceneEvent(QEvent *event)
This virtual function receives events to this item.
void sendControlEvent(QEvent *e)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define qApp
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
QGraphicsTextItemPrivate * dd
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ setDefaultTextColor()

void QGraphicsTextItem::setDefaultTextColor ( const QColor c)

Sets the color for unformatted text to col.

Definition at line 10559 of file qgraphicsitem.cpp.

10560 {
10561  QTextControl *c = dd->textControl();
10562  QPalette pal = c->palette();
10563  QColor old = pal.color(QPalette::Text);
10564  pal.setColor(QPalette::Text, col);
10565  c->setPalette(pal);
10566  if (old != col)
10567  update();
10568 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setPalette(const QPalette &pal)
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
QTextControl * textControl() const
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
QPalette palette() const
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
QGraphicsTextItemPrivate * dd
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61

◆ setDocument()

void QGraphicsTextItem::setDocument ( QTextDocument document)

Sets the text document document on the item.

Definition at line 10711 of file qgraphicsitem.cpp.

10712 {
10713  dd->textControl()->setDocument(document);
10715 }
QSizeF size() const
void setDocument(QTextDocument *document)
void _q_updateBoundingRect(const QSizeF &)
QTextControl * textControl() const
QGraphicsTextItemPrivate * dd

◆ setExtension()

void QGraphicsTextItem::setExtension ( Extension  extension,
const QVariant variant 
)
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 11003 of file qgraphicsitem.cpp.

11004 {
11006  Q_UNUSED(variant);
11007 }
QVariant extension(const QVariant &variant) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setFont()

void QGraphicsTextItem::setFont ( const QFont font)

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

See also
font()

Definition at line 10551 of file qgraphicsitem.cpp.

Referenced by QGraphicsScene::addText().

10552 {
10553  dd->textControl()->document()->setDefaultFont(font);
10554 }
QTextControl * textControl() const
QTextDocument * document() const
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
QGraphicsTextItemPrivate * dd

◆ 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 10505 of file qgraphicsitem.cpp.

10506 {
10507  dd->textControl()->setHtml(text);
10508 }
QTextControl * textControl() const
void setHtml(const QString &text)
QGraphicsTextItemPrivate * dd

◆ setOpenExternalLinks()

void QGraphicsTextItem::setOpenExternalLinks ( bool  open)

Definition at line 11217 of file qgraphicsitem.cpp.

11218 {
11220 }
QTextControl * textControl() const
QGraphicsTextItemPrivate * dd
int open(const char *, int,...)
void setOpenExternalLinks(bool open)

◆ 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 10529 of file qgraphicsitem.cpp.

Referenced by QGraphicsTextItem().

10530 {
10531  dd->textControl()->setPlainText(text);
10532 }
void setPlainText(const QString &text)
QTextControl * textControl() const
QGraphicsTextItemPrivate * dd

◆ setTabChangesFocus()

void QGraphicsTextItem::setTabChangesFocus ( bool  b)

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

Since
4.5

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

See also
tabChangesFocus(), ItemIsFocusable, textInteractionFlags()

Definition at line 11182 of file qgraphicsitem.cpp.

11183 {
11184  dd->tabChangesFocus = b;
11185 }
QGraphicsTextItemPrivate * dd

◆ setTextCursor()

void QGraphicsTextItem::setTextCursor ( const QTextCursor cursor)

Definition at line 11242 of file qgraphicsitem.cpp.

11243 {
11244  dd->textControl()->setTextCursor(cursor);
11245 }
void setTextCursor(const QTextCursor &cursor)
QTextControl * textControl() const
QGraphicsTextItemPrivate * dd

◆ 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 11145 of file qgraphicsitem.cpp.

11146 {
11149  else
11151 
11153 }
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
QTextControl * textControl() const
void setFlags(GraphicsItemFlags flags)
Sets the item flags to flags.
GraphicsItemFlags flags() const
Returns this item&#39;s flags.
QGraphicsTextItemPrivate * dd

◆ 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 10679 of file qgraphicsitem.cpp.

10680 {
10681  dd->textControl()->setTextWidth(width);
10682 }
QTextControl * textControl() const
void setTextWidth(qreal width)
QGraphicsTextItemPrivate * dd

◆ shape()

QPainterPath QGraphicsTextItem::shape ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10589 of file qgraphicsitem.cpp.

10590 {
10591  if (!dd->control)
10592  return QPainterPath();
10593  QPainterPath path;
10594  path.addRect(dd->boundingRect);
10595  return path;
10596 }
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
QGraphicsTextItemPrivate * dd

◆ supportsExtension()

bool QGraphicsTextItem::supportsExtension ( Extension  extension) const
protectedvirtual
Warning
This function is not part of the public interface.

Reimplemented from QGraphicsItem.

Definition at line 10994 of file qgraphicsitem.cpp.

10995 {
10997  return false;
10998 }
QVariant extension(const QVariant &variant) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ tabChangesFocus()

bool QGraphicsTextItem::tabChangesFocus ( ) const

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

Since
4.5

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

See also
setTabChangesFocus()

Definition at line 11200 of file qgraphicsitem.cpp.

11201 {
11202  return dd->tabChangesFocus;
11203 }
QGraphicsTextItemPrivate * dd

◆ 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 11247 of file qgraphicsitem.cpp.

11248 {
11249  if (!dd->control)
11250  return QTextCursor();
11251  return dd->control->textCursor();
11252 }
QTextCursor textCursor() const
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
QGraphicsTextItemPrivate * dd

◆ textInteractionFlags()

Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags ( ) const

Returns the current text interaction flags.

See also
setTextInteractionFlags()

Definition at line 11160 of file qgraphicsitem.cpp.

11161 {
11162  if (!dd->control)
11163  return Qt::NoTextInteraction;
11164  return dd->control->textInteractionFlags();
11165 }
Qt::TextInteractionFlags textInteractionFlags
QGraphicsTextItemPrivate * dd

◆ 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 10692 of file qgraphicsitem.cpp.

10693 {
10694  if (!dd->control)
10695  return -1;
10696  return dd->control->textWidth();
10697 }
qreal textWidth() const
QGraphicsTextItemPrivate * dd

◆ 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 10489 of file qgraphicsitem.cpp.

10490 {
10491 #ifndef QT_NO_TEXTHTMLPARSER
10492  if (dd->control)
10493  return dd->control->toHtml();
10494 #endif
10495  return QString();
10496 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toHtml() const
QGraphicsTextItemPrivate * dd

◆ 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 10515 of file qgraphicsitem.cpp.

10516 {
10517  if (dd->control)
10518  return dd->control->toPlainText();
10519  return QString();
10520 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toPlainText() const
QGraphicsTextItemPrivate * dd

◆ type()

int QGraphicsTextItem::type ( ) const
virtual

Reimplemented Function

Reimplemented from QGraphicsItem.

Definition at line 10658 of file qgraphicsitem.cpp.

10659 {
10660  return Type;
10661 }

Friends and Related Functions

◆ QGraphicsTextItemPrivate

Definition at line 1061 of file qgraphicsitem.h.

Properties

◆ dd

QGraphicsTextItemPrivate* QGraphicsTextItem::dd
private

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