QGraphicsTextItem Class Reference
[QtGui module]
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text. More...
Inherits QObject and QGraphicsItem.
Methods
- __init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)
- __init__ (self, QString text, QGraphicsItem parent = None, QGraphicsScene scene = None)
- adjustSize (self)
- QRectF boundingRect (self)
- bool contains (self, QPointF point)
- contextMenuEvent (self, QGraphicsSceneContextMenuEvent event)
- QColor defaultTextColor (self)
- QTextDocument document (self)
- dragEnterEvent (self, QGraphicsSceneDragDropEvent event)
- dragLeaveEvent (self, QGraphicsSceneDragDropEvent event)
- dragMoveEvent (self, QGraphicsSceneDragDropEvent event)
- dropEvent (self, QGraphicsSceneDragDropEvent event)
- focusInEvent (self, QFocusEvent event)
- focusOutEvent (self, QFocusEvent event)
- QFont font (self)
- hoverEnterEvent (self, QGraphicsSceneHoverEvent event)
- hoverLeaveEvent (self, QGraphicsSceneHoverEvent event)
- hoverMoveEvent (self, QGraphicsSceneHoverEvent event)
- inputMethodEvent (self, QInputMethodEvent event)
- QVariant inputMethodQuery (self, Qt.InputMethodQuery query)
- bool isObscuredBy (self, QGraphicsItem item)
- keyPressEvent (self, QKeyEvent event)
- keyReleaseEvent (self, QKeyEvent event)
- mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent event)
- mouseMoveEvent (self, QGraphicsSceneMouseEvent event)
- mousePressEvent (self, QGraphicsSceneMouseEvent event)
- mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
- QPainterPath opaqueArea (self)
- bool openExternalLinks (self)
- paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
- bool sceneEvent (self, QEvent event)
- setDefaultTextColor (self, QColor c)
- setDocument (self, QTextDocument document)
- setFont (self, QFont font)
- setHtml (self, QString html)
- setOpenExternalLinks (self, bool open)
- setPlainText (self, QString text)
- setTextCursor (self, QTextCursor cursor)
- setTextInteractionFlags (self, Qt.TextInteractionFlags flags)
- setTextWidth (self, float width)
- QPainterPath shape (self)
- QTextCursor textCursor (self)
- Qt.TextInteractionFlags textInteractionFlags (self)
- float textWidth (self)
- QString toHtml (self)
- QString toPlainText (self)
- int type (self)
Qt Signals
Detailed Description
The QGraphicsTextItem class provides a text item that you can add to a QGraphicsScene to display formatted text.
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.TextEditable flag using setTextInteractionFlags().
See also QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, and The Graphics View Framework.
Method Documentation
QGraphicsTextItem.__init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
The scene argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a QGraphicsTextItem. parent and scene are passed to QGraphicsItem's constructor.
QGraphicsTextItem.__init__ (self, QString text, QGraphicsItem parent = None, QGraphicsScene scene = None)
The parent argument, if not None, causes self to be owned by Qt instead of PyQt.
The scene argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a QGraphicsTextItem, using text as the default plain text. parent and scene are passed to QGraphicsItem's constructor.
QGraphicsTextItem.adjustSize (self)
Adjusts the text item to a reasonable size.
QRectF QGraphicsTextItem.boundingRect (self)
bool QGraphicsTextItem.contains (self, QPointF point)
QColor QGraphicsTextItem.defaultTextColor (self)
Returns the default text color that is used to for unformatted text.
See also setDefaultTextColor().
QTextDocument QGraphicsTextItem.document (self)
Returns the item's text document.
See also setDocument().
QGraphicsTextItem.focusInEvent (self, QFocusEvent event)
QGraphicsTextItem.focusOutEvent (self, QFocusEvent event)
QFont QGraphicsTextItem.font (self)
Returns the item's font, which is used to render the text.
See also setFont().
QGraphicsTextItem.inputMethodEvent (self, QInputMethodEvent event)
bool QGraphicsTextItem.isObscuredBy (self, QGraphicsItem item)
QGraphicsTextItem.keyPressEvent (self, QKeyEvent event)
QGraphicsTextItem.keyReleaseEvent (self, QKeyEvent event)
QGraphicsTextItem.mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent event)
QGraphicsTextItem.mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
QPainterPath QGraphicsTextItem.opaqueArea (self)
bool QGraphicsTextItem.openExternalLinks (self)
bool QGraphicsTextItem.sceneEvent (self, QEvent event)
QGraphicsTextItem.setDefaultTextColor (self, QColor c)
Sets the color for unformatted text to col.
See also defaultTextColor().
QGraphicsTextItem.setDocument (self, QTextDocument document)
Sets the text document document on the item.
See also document().
QGraphicsTextItem.setFont (self, QFont font)
Sets the font used to render the text item to font.
See also font().
QGraphicsTextItem.setHtml (self, QString html)
Sets the item's text to text, assuming that text is HTML formatted.
See also toHtml().
QGraphicsTextItem.setOpenExternalLinks (self, bool open)
QGraphicsTextItem.setPlainText (self, QString text)
Sets the item's text to text.
See also toHtml().
QGraphicsTextItem.setTextCursor (self, QTextCursor cursor)
QGraphicsTextItem.setTextInteractionFlags (self, 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. Setting a value different to Qt.NoTextInteraction will also set the ItemIsFocusable QGraphicsItem flag.
By default, the text is read-only. To transform the item into an editor, set the Qt.TextEditable flag.
See also textInteractionFlags().
QGraphicsTextItem.setTextWidth (self, float 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.
See also textWidth().
QPainterPath QGraphicsTextItem.shape (self)
QTextCursor QGraphicsTextItem.textCursor (self)
Returns the current text interaction flags.
See also setTextInteractionFlags().
float QGraphicsTextItem.textWidth (self)
Returns the text width.
See also setTextWidth().
QString QGraphicsTextItem.toHtml (self)
Returns the item's text converted to HTML, or an empty QString if no text has been set.
See also setHtml().
QString QGraphicsTextItem.toPlainText (self)
Returns the item's text converted to plain text, or an empty QString if no text has been set.
See also setPlainText().
int QGraphicsTextItem.type (self)
Qt Signal Documentation
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. link is the link that was clicked.
See also setTextInteractionFlags().
void linkHovered (const QString&)
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().