[QtGui module]
该QGraphicsTextItem类提供了一个文本项,您可以添加到QGraphicsScene显示格式化文本。More…
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)
setTabChangesFocus (self, bool b)
setTextCursor (self, QTextCursor cursor)
setTextInteractionFlags (self, Qt.TextInteractionFlags flags)
setTextWidth (self, float width)
QPainterPath shape (self)
bool tabChangesFocus (self)
QTextCursor textCursor (self)
Qt.TextInteractionFlags textInteractionFlags (self)
float textWidth (self)
QString toHtml (self)
QString toPlainText (self)
int type (self)
Qt Signals
void linkActivated (const QString&)
void linkHovered (const QString&)
Detailed Description
该QGraphicsTextItem类提供了一个文本项,您可以添加到QGraphicsScene显示格式化文本。
如果只需要显示在一个项目纯文本,可以考虑使用QGraphicsSimpleTextItem代替。
要设置项的文本,一个传递QString到QGraphicsTextItem的构造函数,或调用setHtml()/setPlainText( ) 。
QGraphicsTextItem使用文本的格式大小和相关的字体提供合理的实施boundingRect( )shape()和contains( ) 。你可以通过调用设置字体setFont( ) 。
它有可能使该项目可编辑通过设置Qt.TextEditorInteraction使用标志setTextInteractionFlags( ) 。
该项目的首选文本的宽度可以使用设置setTextWidth( ),并使用获得的textWidth( ) 。
Note:为了使在中心的HTML文本,该项目的文本宽度必须设置。
Note:QGraphicsTextItem接受hover events在默认情况下。您可以更改此setAcceptHoverEvents()。
Method Documentation
QGraphicsTextItem.__init__ (self, QGraphicsItem parent = None, QGraphicsScene scene = None)
该parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
该scene的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
构造一个QGraphicsTextItem。parent被传递给QGraphicsItem的构造。
See also QGraphicsScene.addItem( ) 。
QGraphicsTextItem.__init__ (self, QString text, QGraphicsItem parent = None, QGraphicsScene scene = None)
该parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
该scene的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
构造一个QGraphicsTextItem,使用text作为默认的纯文本。parent被传递给QGraphicsItem的构造。
See also QGraphicsScene.addItem( ) 。
QGraphicsTextItem.adjustSize (self)
调整文本项到一个合理的规模。
QRectF QGraphicsTextItem.boundingRect (self)
从重新实现QGraphicsItem.boundingRect( ) 。
bool QGraphicsTextItem.contains (self, QPointF point)
从重新实现QGraphicsItem.contains( ) 。
QGraphicsTextItem.contextMenuEvent (self, QGraphicsSceneContextMenuEvent event)
从重新实现QGraphicsItem.contextMenuEvent( ) 。
QColor QGraphicsTextItem.defaultTextColor (self)
[
返回用于为无格式文本的默认文本颜色。
](docs_qcolor.html)
See also setDefaultTextColor( ) 。
QTextDocument QGraphicsTextItem.document (self)
[
返回该项目的文本文档。
](docs_qtextdocument.html)
See also setDocument( ) 。
QGraphicsTextItem.dragEnterEvent (self, QGraphicsSceneDragDropEvent event)
从重新实现QGraphicsItem.dragEnterEvent( ) 。
QGraphicsTextItem.dragLeaveEvent (self, QGraphicsSceneDragDropEvent event)
从重新实现QGraphicsItem.dragLeaveEvent( ) 。
QGraphicsTextItem.dragMoveEvent (self, QGraphicsSceneDragDropEvent event)
从重新实现QGraphicsItem.dragMoveEvent( ) 。
QGraphicsTextItem.dropEvent (self, QGraphicsSceneDragDropEvent event)
从重新实现QGraphicsItem.dropEvent( ) 。
QGraphicsTextItem.focusInEvent (self, QFocusEvent event)
从重新实现QGraphicsItem.focusInEvent( ) 。
QGraphicsTextItem.focusOutEvent (self, QFocusEvent event)
从重新实现QGraphicsItem.focusOutEvent( ) 。
QFont QGraphicsTextItem.font (self)
[
返回项的字体,这是用来呈现的文本。
](docs_qfont.html)
QGraphicsTextItem.hoverEnterEvent (self, QGraphicsSceneHoverEvent event)
从重新实现QGraphicsItem.hoverEnterEvent( ) 。
QGraphicsTextItem.hoverLeaveEvent (self, QGraphicsSceneHoverEvent event)
从重新实现QGraphicsItem.hoverLeaveEvent( ) 。
QGraphicsTextItem.hoverMoveEvent (self, QGraphicsSceneHoverEvent event)
从重新实现QGraphicsItem.hoverMoveEvent( ) 。
QGraphicsTextItem.inputMethodEvent (self, QInputMethodEvent event)
从重新实现QGraphicsItem.inputMethodEvent( ) 。
QVariant QGraphicsTextItem.inputMethodQuery (self, Qt.InputMethodQuery query)
从重新实现QGraphicsItem.inputMethodQuery( ) 。
bool QGraphicsTextItem.isObscuredBy (self, QGraphicsItem item)
从重新实现QGraphicsItem.isObscuredBy( ) 。
QGraphicsTextItem.keyPressEvent (self, QKeyEvent event)
从重新实现QGraphicsItem.keyPressEvent( ) 。
QGraphicsTextItem.keyReleaseEvent (self, QKeyEvent event)
从重新实现QGraphicsItem.keyReleaseEvent( ) 。
QGraphicsTextItem.mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent event)
从重新实现QGraphicsItem.mouseDoubleClickEvent( ) 。
QGraphicsTextItem.mouseMoveEvent (self, QGraphicsSceneMouseEvent event)
从重新实现QGraphicsItem.mouseMoveEvent( ) 。
QGraphicsTextItem.mousePressEvent (self, QGraphicsSceneMouseEvent event)
从重新实现QGraphicsItem.mousePressEvent( ) 。
QGraphicsTextItem.mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
从重新实现QGraphicsItem.mouseReleaseEvent( ) 。
QPainterPath QGraphicsTextItem.opaqueArea (self)
从重新实现QGraphicsItem.opaqueArea( ) 。
bool QGraphicsTextItem.openExternalLinks (self)
QGraphicsTextItem.paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
从重新实现QGraphicsItem.paint( ) 。
bool QGraphicsTextItem.sceneEvent (self, QEvent event)
从重新实现QGraphicsItem.sceneEvent( ) 。
QGraphicsTextItem.setDefaultTextColor (self, QColor c)
设置为无格式文本的颜色col。
See also defaultTextColor( ) 。
QGraphicsTextItem.setDocument (self, QTextDocument document)
设置文本文件document该项目。
See also document( ) 。
QGraphicsTextItem.setFont (self, QFont font)
设置用于文本渲染项目的字体font。
See also font( ) 。
QGraphicsTextItem.setHtml (self, QString html)
设置项的文本text,假设该文本是HTML格式的。如果该项目具有键盘输入焦点,此功能也将调用ensureVisible()来确保文本是在所有视口中可见。
See also toHtml( )hasFocus()和QGraphicsSimpleTextItem。
QGraphicsTextItem.setOpenExternalLinks (self, bool open)
QGraphicsTextItem.setPlainText (self, QString text)
设置项的文本text。如果该项目具有键盘输入焦点,此功能也将调用ensureVisible()来确保文本是在所有视口中可见。
See also toHtml()和hasFocus( ) 。
QGraphicsTextItem.setTabChangesFocus (self, bool b)
If b是真的,Tab键将导致小部件来改变焦点,否则, tab键将插入一个标籤到文档中。
在某些情况下文本编辑不应该允许用户输入制表或改变使用的缩进Tab关键,因为这打破了焦点链。默认值为False 。
此功能被引入Qt的4.5 。
See also tabChangesFocus( )ItemIsFocusable和textInteractionFlags( ) 。
QGraphicsTextItem.setTextCursor (self, QTextCursor cursor)
QGraphicsTextItem.setTextInteractionFlags (self, Qt.TextInteractionFlags flags)
设置标志flags指定如何将文本项目应响应用户的输入。
默认为QGraphicsTextItem is Qt.NoTextInteraction。此功能也影响到ItemIsFocusable QGraphicsItem标志通过设置它,如果flags是从不同的Qt.NoTextInteraction并且清除它,否则。
默认情况下,文本是只读的。改造项目到编辑器中,设置Qt.TextEditable标志。
See also textInteractionFlags( ) 。
QGraphicsTextItem.setTextWidth (self, float width)
设置项目的文本的首选宽度。如果实际文本比指定的宽度更宽那么它将被分成多行。
If width被设置为-1,则文本不会断成多行,除非它是通过显式换行符或一个新的段落执行。
默认值是-1 。
需要注意的是QGraphicsTextItem养了QTextDocument在内部,它是用来计算文本宽度。
See also textWidth()和QTextDocument.setTextWidth( ) 。
QPainterPath QGraphicsTextItem.shape (self)
bool QGraphicsTextItem.tabChangesFocus (self)
返回True如果Tab键将导致小部件来改变焦点,否则返回False 。
默认情况下,这种行为被禁止,这个函数将返回False 。
此功能被引入Qt的4.5 。
See also setTabChangesFocus( ) 。
QTextCursor QGraphicsTextItem.textCursor (self)
Qt.TextInteractionFlags QGraphicsTextItem.textInteractionFlags (self)
[
返回当前文本的互动标志。
](docs_index.htm)
See also setTextInteractionFlags( ) 。
float QGraphicsTextItem.textWidth (self)
返回文本的宽度。
宽度的计算方法与QTextDocument那QGraphicsTextItem内部保存。
See also setTextWidth()和QTextDocument.textWidth( ) 。
QString QGraphicsTextItem.toHtml (self)
返回项的文本转换为HTML ,或空QString如果没有文本已定。
See also setHtml( ) 。
QString QGraphicsTextItem.toPlainText (self)
返回项的文本转换为纯文本或空QString如果没有文本已定。
See also setPlainText( ) 。
int QGraphicsTextItem.type (self)
从重新实现QGraphicsItem.type( ) 。
Qt Signal Documentation
void linkActivated (const QString&)
这是该信号的默认超载。
当用户点击一个文本项,它使一个链接这个信号被发射Qt.LinksAccessibleByMouse or Qt.LinksAccessibleByKeyboard。link是被点击的链接。
See also setTextInteractionFlags( ) 。
void linkHovered (const QString&)
这是该信号的默认超载。
当用户将鼠标悬停在一个文本项,使一个链接这个信号被发射Qt.LinksAccessibleByMouse。link是被悬停在链接。
See also setTextInteractionFlags( ) 。