![]() |
Qt 6.x
The Qt SDK
|
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text. More...
#include <qgraphicsitem.h>
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. | |
void | linkHovered (const QString &) |
This signal is emitted when the user hovers over a link on a text item that enables Qt::LinksAccessibleByMouse. | |
![]() | |
void | parentChanged () |
This signal gets emitted whenever the parent of the item changes. | |
void | opacityChanged () |
This signal gets emitted whenever the opacity of the item changes. | |
void | visibleChanged () |
This signal gets emitted whenever the visibility of the item changes. | |
void | enabledChanged () |
This signal gets emitted whenever the item gets enabled or disabled. | |
void | xChanged () |
This signal gets emitted whenever the x position of the item changes. | |
void | yChanged () |
This signal gets emitted whenever the y position of the item changes. | |
void | zChanged () |
This signal gets emitted whenever the z value of the item changes. | |
void | rotationChanged () |
This signal gets emitted whenever the rotation of the item changes. | |
void | scaleChanged () |
This signal is emitted when the scale of the item changes. | |
void | childrenChanged () |
This signal gets emitted whenever the children list changes. | |
void | widthChanged () |
void | heightChanged () |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QGraphicsTextItem (QGraphicsItem *parent=nullptr) | |
Constructs a QGraphicsTextItem. | |
QGraphicsTextItem (const QString &text, QGraphicsItem *parent=nullptr) | |
Constructs a QGraphicsTextItem, using text as the default plain text. | |
~QGraphicsTextItem () | |
Destroys the QGraphicsTextItem. | |
QString | toHtml () const |
Returns the item's text converted to HTML, or an empty QString if no text has been set. | |
void | setHtml (const QString &html) |
Sets the item's text to text, assuming that text is HTML formatted. | |
QString | toPlainText () const |
Returns the item's text converted to plain text, or an empty QString if no text has been set. | |
void | setPlainText (const QString &text) |
Sets the item's text to text. | |
QFont | font () const |
Returns the item's font, which is used to render the text. | |
void | setFont (const QFont &font) |
Sets the font used to render the text item to font. | |
void | setDefaultTextColor (const QColor &c) |
Sets the color for unformatted text to col. | |
QColor | defaultTextColor () const |
Returns the default text color that is used for unformatted text. | |
QRectF | boundingRect () const override |
\reimp | |
QPainterPath | shape () const override |
\reimp | |
bool | contains (const QPointF &point) const override |
\reimp | |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
\reimp | |
bool | isObscuredBy (const QGraphicsItem *item) const override |
\reimp | |
QPainterPath | opaqueArea () const override |
\reimp | |
int | type () const override |
\reimp | |
void | setTextWidth (qreal width) |
Sets the preferred width for the item's text. | |
qreal | textWidth () const |
Returns the text width. | |
void | adjustSize () |
Adjusts the text item to a reasonable size. | |
void | setDocument (QTextDocument *document) |
Sets the text document document on the item. | |
QTextDocument * | document () const |
Returns the item's text document. | |
void | setTextInteractionFlags (Qt::TextInteractionFlags flags) |
Sets the flags flags to specify how the text item should react to user input. | |
Qt::TextInteractionFlags | textInteractionFlags () const |
Returns the current text interaction flags. | |
void | setTabChangesFocus (bool b) |
bool | tabChangesFocus () const |
void | setOpenExternalLinks (bool open) |
bool | openExternalLinks () const |
Specifies whether QGraphicsTextItem should automatically open links using QDesktopServices::openUrl() instead of emitting the linkActivated signal. | |
void | setTextCursor (const QTextCursor &cursor) |
QTextCursor | textCursor () const |
This property represents the visible text cursor in an editable text item. | |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) 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. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
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 |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
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 . | |
![]() | |
QGraphicsItem (QGraphicsItem *parent=nullptr) | |
Constructs a QGraphicsItem with the given parent item. | |
virtual | ~QGraphicsItem () |
Destroys the QGraphicsItem and all its children. | |
QGraphicsScene * | scene () const |
Returns the current scene for the item, or \nullptr if the item is not stored in a scene. | |
QGraphicsItem * | parentItem () const |
Returns a pointer to this item's parent item. | |
QGraphicsItem * | topLevelItem () const |
Returns this item's top-level item. | |
QGraphicsObject * | parentObject () const |
QGraphicsWidget * | parentWidget () const |
QGraphicsWidget * | topLevelWidget () const |
QGraphicsWidget * | window () const |
QGraphicsItem * | panel () const |
void | setParentItem (QGraphicsItem *parent) |
Sets this item's parent item to newParent. | |
QList< QGraphicsItem * > | childItems () const |
bool | isWidget () const |
bool | isWindow () const |
bool | isPanel () const |
QGraphicsObject * | toGraphicsObject () |
const QGraphicsObject * | toGraphicsObject () const |
QGraphicsItemGroup * | group () const |
Returns a pointer to this item's item group, or \nullptr if this item is not member of a group. | |
void | setGroup (QGraphicsItemGroup *group) |
Adds this item to the item group group. | |
GraphicsItemFlags | flags () const |
Returns this item's flags. | |
void | setFlag (GraphicsItemFlag flag, bool enabled=true) |
If enabled is true, the item flag flag is enabled; otherwise, it is disabled. | |
void | setFlags (GraphicsItemFlags flags) |
Sets the item flags to 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 |
Returns the current cursor shape for the item. | |
void | setCursor (const QCursor &cursor) |
Sets the current cursor shape for the item to cursor. | |
bool | hasCursor () const |
Returns true if this item has a cursor set; otherwise, false is returned. | |
void | unsetCursor () |
Clears the cursor from this item. | |
bool | isVisible () const |
Returns true if the item is visible; otherwise, false is returned. | |
bool | isVisibleTo (const QGraphicsItem *parent) const |
void | setVisible (bool visible) |
If visible is true, the item is made visible. | |
void | hide () |
Hides the item (items are visible by default). | |
void | show () |
Shows the item (items are visible by default). | |
bool | isEnabled () const |
Returns true if the item is enabled; otherwise, false is returned. | |
void | setEnabled (bool enabled) |
If enabled is true, the item is enabled; otherwise, it is disabled. | |
bool | isSelected () const |
Returns true if this item is selected; otherwise, false is returned. | |
void | setSelected (bool selected) |
If selected is true and this item is selectable, this item is selected; otherwise, it is unselected. | |
bool | acceptDrops () const |
Returns true if this item can accept drag and drop events; otherwise, returns false . | |
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. | |
qreal | opacity () const |
qreal | effectiveOpacity () const |
void | setOpacity (qreal opacity) |
Qt::MouseButtons | acceptedMouseButtons () const |
Returns the mouse buttons that this item accepts mouse events for. | |
void | setAcceptedMouseButtons (Qt::MouseButtons buttons) |
Sets the mouse buttons that this item accepts mouse events for. | |
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 |
Returns true if this item is active, and it or its \l{focusProxy()}{focus proxy} has keyboard input focus; otherwise, returns false . | |
void | setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason) |
Gives keyboard input focus to this item. | |
void | clearFocus () |
Takes keyboard input focus from the item. | |
QGraphicsItem * | focusProxy () const |
void | setFocusProxy (QGraphicsItem *item) |
QGraphicsItem * | focusItem () const |
QGraphicsItem * | focusScopeItem () const |
void | grabMouse () |
void | ungrabMouse () |
void | grabKeyboard () |
void | ungrabKeyboard () |
QPointF | pos () const |
Returns the position of the item in parent coordinates. | |
qreal | x () const |
This convenience function is equivalent to calling pos().x(). | |
void | setX (qreal x) |
qreal | y () const |
This convenience function is equivalent to calling pos().y(). | |
void | setY (qreal y) |
QPointF | scenePos () const |
Returns the item's position in scene coordinates. | |
void | setPos (const QPointF &pos) |
Sets the position of the item to pos, which is in parent coordinates. | |
void | setPos (qreal x, qreal y) |
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 setPos(QPointF(x, y)). | |
void | moveBy (qreal dx, qreal dy) |
Moves the item by dx points horizontally, and dy point vertically. | |
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. | |
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). | |
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) |
This virtual function is called twice for all items by the QGraphicsScene::advance() slot. | |
qreal | zValue () const |
Returns the Z-value of the item. | |
void | setZValue (qreal z) |
Sets the Z-value of the item to z. | |
void | stackBefore (const QGraphicsItem *sibling) |
virtual QRectF | boundingRect () const =0 |
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be restricted to inside an item's bounding rect. | |
QRectF | childrenBoundingRect () const |
Returns the bounding rect of this item's descendants (i.e., its children, their children, etc.) in local coordinates. | |
QRectF | sceneBoundingRect () const |
Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(). | |
virtual QPainterPath | shape () const |
Returns the shape of this item as a QPainterPath in local coordinates. | |
bool | isClipped () const |
Returns true if this item is clipped. | |
QPainterPath | clipPath () const |
virtual bool | contains (const QPointF &point) const |
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned. | |
virtual bool | collidesWithItem (const QGraphicsItem *other, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
Returns true if this item collides with other; otherwise returns false . | |
virtual bool | collidesWithPath (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
Returns true if this item collides with path. | |
QList< QGraphicsItem * > | collidingItems (Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
Returns a list of all items that collide with this item. | |
bool | isObscured (const QRectF &rect=QRectF()) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | isObscured (qreal x, qreal y, qreal w, qreal h) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
virtual bool | isObscuredBy (const QGraphicsItem *item) const |
Returns true if this item's bounding rect is completely obscured by the opaque shape of item. | |
virtual QPainterPath | opaqueArea () const |
This virtual function returns a shape representing the area where this item is opaque. | |
QRegion | boundingRegion (const QTransform &itemToDeviceTransform) const |
qreal | boundingRegionGranularity () const |
void | setBoundingRegionGranularity (qreal granularity) |
virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)=0 |
This function, which is usually called by QGraphicsView, paints the contents of an item in local coordinates. | |
void | update (const QRectF &rect=QRectF()) |
Schedules a redraw of the area covered by rect in this item. | |
void | update (qreal x, qreal y, qreal width, qreal height) |
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 update(QRectF(x, y, width, height)). | |
void | scroll (qreal dx, qreal dy, const QRectF &rect=QRectF()) |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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 |
Maps the polygon polygon, which is in this item's coordinate system, to item's coordinate system, and returns the mapped polygon. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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 |
Maps the polygon polygon, which is in item's coordinate system, to this item's coordinate system, and returns the mapped polygon. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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)). | |
QPointF | mapToParent (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 mapToParent(QPointF(x, y)). | |
QPointF | mapToScene (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 mapToScene(QPointF(x, y)). | |
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 |
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)). | |
QPointF | mapFromParent (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 mapFromParent(QPointF(x, y)). | |
QPointF | mapFromScene (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 mapFromScene(QPointF(x, y)). | |
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 |
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). | |
QGraphicsItem * | commonAncestorItem (const QGraphicsItem *other) const |
bool | isUnderMouse () const |
QVariant | data (int key) const |
Returns this item's custom data for the key key as a QVariant. | |
void | setData (int key, const QVariant &value) |
Sets this item's custom data for the key key to value. | |
Qt::InputMethodHints | inputMethodHints () const |
Returns the current input method hints of this item. | |
void | setInputMethodHints (Qt::InputMethodHints hints) |
Sets the current input method hints of this item to hints. | |
virtual int | type () const |
Returns the type of an item as an int. | |
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. | |
void | removeSceneEventFilter (QGraphicsItem *filterItem) |
Removes an event filter on this item from filterItem. | |
Protected Member Functions | |
bool | sceneEvent (QEvent *event) override |
\reimp | |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
\reimp | |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) override |
\reimp | |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
\reimp | |
void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
\reimp | |
void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override |
\reimp | |
void | keyPressEvent (QKeyEvent *event) override |
\reimp | |
void | keyReleaseEvent (QKeyEvent *event) override |
\reimp | |
void | focusInEvent (QFocusEvent *event) override |
\reimp | |
void | focusOutEvent (QFocusEvent *event) override |
\reimp | |
void | dragEnterEvent (QGraphicsSceneDragDropEvent *event) override |
\reimp | |
void | dragLeaveEvent (QGraphicsSceneDragDropEvent *event) override |
\reimp | |
void | dragMoveEvent (QGraphicsSceneDragDropEvent *event) override |
\reimp | |
void | dropEvent (QGraphicsSceneDragDropEvent *event) override |
\reimp | |
void | inputMethodEvent (QInputMethodEvent *event) override |
\reimp | |
void | hoverEnterEvent (QGraphicsSceneHoverEvent *event) override |
\reimp | |
void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) override |
\reimp | |
void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override |
\reimp | |
QVariant | inputMethodQuery (Qt::InputMethodQuery query) const override |
\reimp | |
bool | supportsExtension (Extension extension) const override |
void | setExtension (Extension extension, const QVariant &variant) override |
QVariant | extension (const QVariant &variant) const override |
![]() | |
QGraphicsObject (QGraphicsItemPrivate &dd, QGraphicsItem *parent) | |
Constructs a QGraphicsObject with parent. | |
bool | event (QEvent *ev) override |
\reimp | |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
![]() | |
void | updateMicroFocus () |
Updates the item's micro focus. | |
virtual bool | sceneEventFilter (QGraphicsItem *watched, QEvent *event) |
Filters events for the item watched. | |
virtual bool | sceneEvent (QEvent *event) |
This virtual function receives events to this item. | |
virtual void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) |
This event handler can be reimplemented in a subclass to process context menu events. | |
virtual void | dragEnterEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented to receive drag enter events for this item. | |
virtual void | dragLeaveEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented to receive drag leave events for this item. | |
virtual void | dragMoveEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented to receive drag move events for this item. | |
virtual void | dropEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented to receive drop events for this item. | |
virtual void | focusInEvent (QFocusEvent *event) |
This event handler, for event event, can be reimplemented to receive focus in events for this item. | |
virtual void | focusOutEvent (QFocusEvent *event) |
This event handler, for event event, can be reimplemented to receive focus out events for this item. | |
virtual void | hoverEnterEvent (QGraphicsSceneHoverEvent *event) |
This event handler, for event event, can be reimplemented to receive hover enter events for this item. | |
virtual void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) |
This event handler, for event event, can be reimplemented to receive hover move events for this item. | |
virtual void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) |
This event handler, for event event, can be reimplemented to receive hover leave events for this item. | |
virtual void | keyPressEvent (QKeyEvent *event) |
This event handler, for event event, can be reimplemented to receive key press events for this item. | |
virtual void | keyReleaseEvent (QKeyEvent *event) |
This event handler, for event event, can be reimplemented to receive key release events for this item. | |
virtual void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event event, can be reimplemented to receive mouse press events for this item. | |
virtual void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event event, can be reimplemented to receive mouse move events for this item. | |
virtual void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event event, can be reimplemented to receive mouse release events for this item. | |
virtual void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event event, can be reimplemented to receive mouse double-click events for this item. | |
virtual void | wheelEvent (QGraphicsSceneWheelEvent *event) |
This event handler, for event event, can be reimplemented to receive wheel events for this item. | |
virtual void | inputMethodEvent (QInputMethodEvent *event) |
This event handler, for event event, can be reimplemented to receive input method events for this item. | |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
This method is only relevant for input items. | |
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. | |
virtual bool | supportsExtension (Extension extension) const |
virtual void | setExtension (Extension extension, const QVariant &variant) |
virtual QVariant | extension (const QVariant &variant) const |
QGraphicsItem (QGraphicsItemPrivate &dd, QGraphicsItem *parent) | |
void | addToIndex () |
void | removeFromIndex () |
void | prepareGeometryChange () |
Prepares the item for a geometry change. | |
Friends | |
class | QGraphicsTextItemPrivate |
Additional Inherited Members | |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
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::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a 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) |
![]() | |
enum | Extension { UserExtension = 0x80000000 } |
![]() | |
void | updateMicroFocus () |
Updates the item's micro focus. | |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
QScopedPointer< QGraphicsItemPrivate > | d_ptr |
![]() | |
QGraphicsObject * | parent |
the parent of the item | |
qreal | opacity |
the opacity of the item | |
bool | enabled |
whether the item is enabled or not | |
bool | visible |
whether the item is visible or not | |
QPointF | pos |
the position of the item | |
qreal | x |
the x position of the item | |
qreal | y |
the y position of the item | |
qreal | z |
the z value of the item | |
qreal | rotation |
the rotation of the item in degrees. | |
qreal | scale |
the scale of the item. | |
QPointF | transformOriginPoint |
the transformation origin | |
![]() | |
QString | objectName |
the name of this object | |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
![]() | |
T | qgraphicsitem_cast (QGraphicsItem *item) |
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text.
\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().
Definition at line 818 of file qgraphicsitem.h.
anonymous enum |
Enumerator | |
---|---|
Type |
Definition at line 850 of file qgraphicsitem.h.
|
explicit |
Constructs a QGraphicsTextItem.
parent is passed to QGraphicsItem's constructor.
Definition at line 9708 of file qgraphicsitem.cpp.
References QGraphicsItem::ItemUsesExtendedStyleOption, QGraphicsTextItemPrivate::qq, QGraphicsItem::setAcceptDrops(), QGraphicsItem::setAcceptHoverEvents(), and QGraphicsItem::setFlag().
|
explicit |
Constructs a QGraphicsTextItem, using text as the default plain text.
parent is passed to QGraphicsItem's constructor.
Definition at line 9690 of file qgraphicsitem.cpp.
References QString::isEmpty(), QGraphicsItem::ItemUsesExtendedStyleOption, QGraphicsTextItemPrivate::qq, QGraphicsItem::setAcceptDrops(), QGraphicsItem::setAcceptHoverEvents(), QGraphicsItem::setFlags(), setPlainText(), and text.
QGraphicsTextItem::~QGraphicsTextItem | ( | ) |
Destroys the QGraphicsTextItem.
Definition at line 9721 of file qgraphicsitem.cpp.
void QGraphicsTextItem::adjustSize | ( | ) |
Adjusts the text item to a reasonable size.
Definition at line 9944 of file qgraphicsitem.cpp.
References QWidgetTextControl::adjustSize(), and QGraphicsTextItemPrivate::control.
|
overridevirtual |
\reimp
Implements QGraphicsItem.
Definition at line 9823 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::boundingRect.
Referenced by QGraphicsTextItemPrivate::_q_mouseOnEdge(), and mouseReleaseEvent().
|
overridevirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9843 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::boundingRect, and QRectF::contains().
Referenced by mouseReleaseEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10104 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
QColor QGraphicsTextItem::defaultTextColor | ( | ) | const |
Returns the default text color that is used for unformatted text.
Definition at line 9815 of file qgraphicsitem.cpp.
References QPalette::color(), QWidgetTextControl::palette(), QPalette::Text, and QGraphicsTextItemPrivate::textControl().
QTextDocument * QGraphicsTextItem::document | ( | ) | const |
Returns the item's text document.
Definition at line 9962 of file qgraphicsitem.cpp.
References QWidgetTextControl::document(), and QGraphicsTextItemPrivate::textControl().
Referenced by setDocument().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10149 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10157 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10165 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10173 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
Reimplemented from QGraphicsItem.
Definition at line 10256 of file qgraphicsitem.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10128 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::clickCausedFocus, Qt::MouseFocusReason, QGraphicsTextItemPrivate::sendControlEvent(), and QGraphicsItem::update().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10140 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent(), and QGraphicsItem::update().
QFont QGraphicsTextItem::font | ( | ) | const |
Returns the item's font, which is used to render the text.
Definition at line 9781 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, QTextDocument::defaultFont, and QWidgetTextControl::document().
Referenced by setFont().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10189 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10205 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10197 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10181 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10213 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, QGraphicsTextItemPrivate::controlOffset(), Qt::ImEnabled, Qt::ImHints, QGraphicsItem::inputMethodHints(), QWidgetTextControl::inputMethodQuery(), QGraphicsItem::isEnabled(), QPointF::toPoint(), QVariant::toRectF(), and QRectF::translated().
|
overridevirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9884 of file qgraphicsitem.cpp.
References QGraphicsItem::isObscuredBy(), and item.
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10112 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10120 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::sendControlEvent().
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.
Referenced by QGraphicsTextItemPrivate::textControl().
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.
Referenced by QGraphicsTextItemPrivate::textControl().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10086 of file qgraphicsitem.cpp.
References QGraphicsItem::hasFocus(), QGraphicsItem::mouseDoubleClickEvent(), QGraphicsTextItemPrivate::sendControlEvent(), and QGraphicsTextItemPrivate::useDefaultImpl.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10047 of file qgraphicsitem.cpp.
References QGraphicsItem::mouseMoveEvent(), QGraphicsTextItemPrivate::sendControlEvent(), and QGraphicsTextItemPrivate::useDefaultImpl.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10022 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::_q_mouseOnEdge(), QGraphicsTextItemPrivate::control, QGraphicsItem::d_ptr, QGraphicsItem::ItemIsMovable, QGraphicsItem::ItemIsSelectable, Qt::LeftButton, QGraphicsItem::mousePressEvent(), Qt::NoTextInteraction, QGraphicsTextItemPrivate::sendControlEvent(), QWidgetTextControl::textInteractionFlags, and QGraphicsTextItemPrivate::useDefaultImpl.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 10060 of file qgraphicsitem.cpp.
References boundingRect(), QGraphicsTextItemPrivate::clickCausedFocus, contains(), QGraphicsTextItemPrivate::control, QWidgetPrivate::handleSoftwareInputPanel(), Qt::LeftButton, QGraphicsItem::mouseReleaseEvent(), Qt::NoTextInteraction, qt_widget_private(), QGraphicsTextItemPrivate::sendControlEvent(), Qt::TextEditable, QWidgetTextControl::textInteractionFlags, QGraphicsTextItemPrivate::useDefaultImpl, and widget.
|
overridevirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9892 of file qgraphicsitem.cpp.
References QGraphicsItem::opaqueArea().
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 10448 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, and QWidgetTextControl::openExternalLinks.
|
overridevirtual |
\reimp
Implements QGraphicsItem.
Definition at line 9851 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::boundingRect, QGraphicsTextItemPrivate::control, QGraphicsTextItemPrivate::controlOffset(), QWidgetTextControl::document(), QTextDocument::documentLayout(), QWidgetTextControl::drawContents(), layout, painter, Q_UNUSED, qt_graphicsItem_highlightSelected(), QPainter::restore(), QPainter::save(), QStyle::State_HasFocus, QStyle::State_Selected, QPainter::translate(), and widget.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9970 of file qgraphicsitem.cpp.
References QEvent::ContextMenu, QEvent::FocusIn, QEvent::FocusOut, QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave, QEvent::GraphicsSceneDragMove, QEvent::GraphicsSceneDrop, QEvent::GraphicsSceneHoverEnter, QEvent::GraphicsSceneHoverLeave, QEvent::GraphicsSceneHoverMove, QEvent::GraphicsSceneMouseDoubleClick, QEvent::GraphicsSceneMouseMove, QEvent::GraphicsSceneMousePress, QEvent::GraphicsSceneMouseRelease, Qt::ImQueryInput, QEvent::InputMethod, QGuiApplication::inputMethod(), Qt::Key_Backtab, Qt::Key_Tab, QEvent::KeyPress, QEvent::KeyRelease, QInputMethod::reset(), QGraphicsItem::sceneEvent(), QGraphicsTextItemPrivate::sendControlEvent(), QEvent::ShortcutOverride, QGraphicsTextItemPrivate::tabChangesFocus, and QInputMethod::update().
Sets the color for unformatted text to col.
Definition at line 9801 of file qgraphicsitem.cpp.
References QPalette::color(), QPalette::setColor(), QPalette::Text, QGraphicsTextItemPrivate::textControl(), and QGraphicsItem::update().
void QGraphicsTextItem::setDocument | ( | QTextDocument * | document | ) |
Sets the text document document on the item.
Definition at line 9953 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::_q_updateBoundingRect(), QGraphicsTextItemPrivate::control, document(), QWidgetTextControl::setDocument(), QWidgetTextControl::size(), and QGraphicsTextItemPrivate::textControl().
|
overrideprotectedvirtual |
Reimplemented from QGraphicsItem.
Definition at line 10247 of file qgraphicsitem.cpp.
References extension(), Q_UNUSED, and variant.
Sets the font used to render the text item to font.
Definition at line 9793 of file qgraphicsitem.cpp.
References QWidgetTextControl::document(), font(), QTextDocument::setDefaultFont(), and QGraphicsTextItemPrivate::textControl().
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.
Definition at line 9747 of file qgraphicsitem.cpp.
References QWidgetTextControl::setHtml(), text, and QGraphicsTextItemPrivate::textControl().
void QGraphicsTextItem::setOpenExternalLinks | ( | bool | open | ) |
Definition at line 10443 of file qgraphicsitem.cpp.
References open(), QWidgetTextControl::setOpenExternalLinks(), and QGraphicsTextItemPrivate::textControl().
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.
Definition at line 9771 of file qgraphicsitem.cpp.
References QWidgetTextControl::setPlainText(), text, and QGraphicsTextItemPrivate::textControl().
Referenced by QGraphicsTextItem().
void QGraphicsTextItem::setTabChangesFocus | ( | bool | b | ) |
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.
Definition at line 10414 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::tabChangesFocus.
void QGraphicsTextItem::setTextCursor | ( | const QTextCursor & | cursor | ) |
Definition at line 10465 of file qgraphicsitem.cpp.
References QGraphicsItem::cursor(), QWidgetTextControl::setTextCursor(), and QGraphicsTextItemPrivate::textControl().
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 10380 of file qgraphicsitem.cpp.
References QGraphicsItem::flags(), QGraphicsItem::ItemAcceptsInputMethod, QGraphicsItem::ItemIsFocusable, Qt::NoTextInteraction, QGraphicsItem::setFlags(), QWidgetTextControl::setTextInteractionFlags(), and QGraphicsTextItemPrivate::textControl().
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.
Definition at line 9921 of file qgraphicsitem.cpp.
References QWidgetTextControl::setTextWidth(), and QGraphicsTextItemPrivate::textControl().
|
overridevirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9831 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::boundingRect, and QGraphicsTextItemPrivate::control.
|
overrideprotectedvirtual |
Reimplemented from QGraphicsItem.
Definition at line 10238 of file qgraphicsitem.cpp.
References extension(), and Q_UNUSED.
bool QGraphicsTextItem::tabChangesFocus | ( | ) | const |
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.
Definition at line 10429 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::tabChangesFocus.
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 10470 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, and QWidgetTextControl::textCursor().
Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags | ( | ) | const |
Returns the current text interaction flags.
Definition at line 10395 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, Qt::NoTextInteraction, and QWidgetTextControl::textInteractionFlags.
qreal QGraphicsTextItem::textWidth | ( | ) | const |
Returns the text width.
The width is calculated with the QTextDocument that QGraphicsTextItem keeps internally.
Definition at line 9934 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, and QWidgetTextControl::textWidth().
QString QGraphicsTextItem::toHtml | ( | ) | const |
Returns the item's text converted to HTML, or an empty QString if no text has been set.
Definition at line 9731 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, and QWidgetTextControl::toHtml().
QString QGraphicsTextItem::toPlainText | ( | ) | const |
Returns the item's text converted to plain text, or an empty QString if no text has been set.
Definition at line 9757 of file qgraphicsitem.cpp.
References QGraphicsTextItemPrivate::control, and QWidgetTextControl::toPlainText().
|
overridevirtual |
\reimp
Reimplemented from QGraphicsItem.
Definition at line 9900 of file qgraphicsitem.cpp.
References Type.
|
friend |
Definition at line 906 of file qgraphicsitem.h.