📄 qtextedit.3qt
字号:
See also pasteSubType(), cut(), and QTextEdit::copy()..SH "void QTextEdit::pasteSubType ( const QCString & subtype )\fC [virtual slot]\fR"Pastes the text with format \fIsubtype\fR from the clipboard into the text edit at the current cursor position. The \fIsubtype\fR can be" plain" or "html"..PPIf there is no text with format \fIsubtype\fR in the clipboard nothing happens..PPSee also paste(), cut(), and QTextEdit::copy()..SH "void QTextEdit::placeCursor ( const QPoint & pos, QTextCursor * c = 0 )\fC [virtual slot]\fR"Places the cursor \fIc\fR at the character which is closest to position \fIpos\fR (in contents coordinates). If \fIc\fR is 0, the default text cursor is used..PPSee also setCursorPosition()..SH "int QTextEdit::pointSize () const"Returns the point size of the font of the current format..PPSee also setFamily(), setCurrentFont(), and setPointSize()..SH "void QTextEdit::redo ()\fC [virtual slot]\fR"Redoes the last operation..PPIf there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens..PPSee also redoAvailable(), undo(), and undoDepth..SH "void QTextEdit::redoAvailable ( bool yes )\fC [signal]\fR"This signal is emitted when the availability of redo changes. If \fIyes\fR is TRUE, then redo() will work until redoAvailable( FALSE ) is next emitted..PPSee also redo() and undoDepth..SH "void QTextEdit::removeParagraph ( int para )\fC [virtual slot]\fR"Removes the paragraph \fIpara\fR..SH "void QTextEdit::removeSelectedText ( int selNum = 0 )\fC [virtual slot]\fR"Deletes the text of selection \fIselNum\fR (by default, the default selection, 0). If there is no selected text nothing happens..PPSee also selectedText and removeSelection()..SH "void QTextEdit::removeSelection ( int selNum = 0 )\fC [virtual slot]\fR"Removes the selection \fIselNum\fR (by default 0). This does not remove the selected text..PPSee also removeSelectedText()..SH "void QTextEdit::repaintChanged ()\fC [protected]\fR"Repaints any paragraphs that have changed..PPAlthough used extensively internally you shouldn't need to call this yourself..SH "void QTextEdit::returnPressed ()\fC [signal]\fR"This signal is emitted if the user pressed the Return or the Enter key..SH "void QTextEdit::scrollToAnchor ( const QString & name )\fC [virtual slot]\fR"Scrolls the text edit to make the text at the anchor called \fIname\fR visible, if it can be found in the document. If the anchor isn't found no scrolling will occur. An anchor is defined using the HTML anchor tag, e.g. \fC<a name="target">\fR..SH "void QTextEdit::scrollToBottom ()\fC [virtual slot]\fR"Scrolls to the bottom of the document and does formatting if required..SH "void QTextEdit::selectAll ( bool select = TRUE )\fC [virtual slot]\fR"If \fIselect\fR is TRUE (the default), all the text is selected as selection 0. If \fIselect\fR is FALSE any selected text is unselected, i.e. the default selection (selection 0) is cleared..PPSee also selectedText..SH "QString QTextEdit::selectedText () const"Returns the selected text (from selection 0) or an empty string if there is no currently selected text (in selection 0). See the "selectedText" property for details..SH "void QTextEdit::selectionChanged ()\fC [signal]\fR"This signal is emitted whenever the selection changes..PPSee also setSelection() and copyAvailable()..SH "void QTextEdit::setAlignment ( int a )\fC [virtual slot]\fR"Sets the alignment of the current paragraph to \fIa\fR. Valid alignments are Qt::AlignLeft, Qt::AlignRight, Qt::AlignJustify and Qt::AlignCenter (which centers horizontally)..PPReimplemented in QMultiLineEdit..SH "void QTextEdit::setBold ( bool b )\fC [virtual slot]\fR"If \fIb\fR is TRUE sets the current format to bold; otherwise sets the current format to non-bold..PPSee also bold()..SH "void QTextEdit::setColor ( const QColor & c )\fC [virtual slot]\fR"Sets the color of the current format, i.e. of the text, to \fIc\fR..PPSee also color() and paper..SH "void QTextEdit::setCurrentFont ( const QFont & f )\fC [virtual slot]\fR"Sets the font of the current format to \fIf\fR..PPSee also currentFont(), setPointSize(), and setFamily()..SH "void QTextEdit::setCursorPosition ( int para, int index )\fC [virtual slot]\fR"Sets the cursor to position \fIindex\fR in paragraph \fIpara\fR..PPSee also getCursorPosition()..SH "void QTextEdit::setFamily ( const QString & fontFamily )\fC [virtual slot]\fR"Sets the font family of the current format to \fIfontFamily\fR..PPSee also family() and setCurrentFont()..SH "void QTextEdit::setItalic ( bool b )\fC [virtual slot]\fR"If \fIb\fR is TRUE sets the current format to italic; otherwise sets the current format to non-italic..PPSee also italic()..SH "void QTextEdit::setLinkUnderline ( bool )\fC [virtual slot]\fR"Sets whether hypertext links will be underlined. See the "linkUnderline" property for details..SH "void QTextEdit::setMimeSourceFactory ( QMimeSourceFactory * factory )\fC [virtual slot]\fR"Sets the text edit's mimesource factory to \fIfactory\fR. See QMimeSourceFactory for further details..PPSee also mimeSourceFactory()..SH "void QTextEdit::setModified ( bool m )\fC [virtual slot]\fR"Sets whether the document has been modified by the user to \fIm\fR. See the "modified" property for details..SH "void QTextEdit::setOverwriteMode ( bool b )\fC [virtual slot]\fR"Sets the text edit's overwrite mode to \fIb\fR. See the "overwriteMode" property for details..SH "void QTextEdit::setPaper ( const QBrush & pap )\fC [virtual slot]\fR"Sets the background (paper) brush to \fIpap\fR. See the "paper" property for details..SH "void QTextEdit::setParagraphBackgroundColor ( int para, const QColor & bg )\fC [virtual slot]\fR"Sets the background color of the paragraph \fIpara\fR to \fIbg\fR..SH "void QTextEdit::setPointSize ( int s )\fC [virtual slot]\fR"Sets the point size of the current format to \fIs\fR..PPNote that if \fIs\fR is zero or negative, the behaviour of this function is not defined..PPSee also pointSize(), setCurrentFont(), and setFamily()..SH "void QTextEdit::setReadOnly ( bool b )\fC [virtual slot]\fR"Sets whether the text edit is read-only to \fIb\fR. See the "readOnly" property for details..SH "void QTextEdit::setSelection ( int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum = 0 )\fC [virtual slot]\fR"Sets a selection which starts at position \fIindexFrom\fR in paragraph \fIparaFrom\fR and ends at position \fIindexTo\fR in paragraph \fIparaTo\fR..PPAny existing selections which have a different id (\fIselNum\fR) are left alone, but if an existing selection has the same id as \fIselNum\fR it is removed and replaced by this selection..PPUses the selection settings of selection \fIselNum\fR. If \fIselNum\fR is 0, this is the default selection..PPThe cursor is moved to the end of the selection if \fIselNum\fR is 0, otherwise the cursor position remains unchanged..PPSee also getSelection() and selectedText..SH "void QTextEdit::setSelectionAttributes ( int selNum, const QColor & back, bool invertText )\fC [virtual slot]\fR"Sets the background color of selection number \fIselNum\fR to \fIback\fR and specifies whether the text of this selection should be inverted with \fIinvertText\fR..PPThis only works for \fIselNum\fR > 0. The default selection (\fIselNum\fR == 0) gets its attributes from the text edit's colorGroup()..SH "void QTextEdit::setStyleSheet ( QStyleSheet * styleSheet )\fC [virtual slot]\fR"Sets the stylesheet to use with this text edit to \fIstyleSheet\fR. Changes will only take effect for new text added with setText() or append()..PPSee also styleSheet()..SH "void QTextEdit::setTabChangesFocus ( bool b )\fC [slot]\fR"Sets whether TAB changes focus or is accepted as input to \fIb\fR. See the "tabChangesFocus" property for details..SH "void QTextEdit::setTabStopWidth ( int ts )\fC [virtual slot]\fR"Sets the tab stop width in pixels to \fIts\fR. See the "tabStopWidth" property for details..SH "void QTextEdit::setText ( const QString & txt )\fC [slot]\fR"Sets the text edit's text to \fItxt\fR. See the "text" property for details..SH "void QTextEdit::setText ( const QString & text, const QString & context )\fC [virtual slot]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPChanges the text of the text edit to the string \fItext\fR and the context to \fIcontext\fR. Any previous text is removed..PP\fItext\fR may be interpreted either as plain text or as rich text, depending on the textFormat(). The default setting is AutoText, i.e. the text edit auto-detects the format from \fItext\fR..PPFor rich text the rendering style and available tags are defined by a styleSheet(); see QStyleSheet for details..PPThe optional \fIcontext\fR is a path which the text edit's QMimeSourceFactory uses to resolve the locations of files and images. (See QTextEdit::QTextEdit().) It is passed to the text edit's QMimeSourceFactory when quering data..PPNote that the undo/redo history is cleared by this function..PPSee also text and textFormat..SH "void QTextEdit::setTextFormat ( TextFormat f )\fC [virtual slot]\fR"Sets the text format: rich text, plain text, log text or auto text to \fIf\fR. See the "textFormat" property for details..SH "void QTextEdit::setUnderline ( bool b )\fC [virtual slot]\fR"If \fIb\fR is TRUE sets the current format to underline; otherwise sets the current format to non-underline..PPSee also underline()..SH "void QTextEdit::setUndoDepth ( int d )\fC [virtual slot]\fR"Sets the depth of the undo history to \fId\fR. See the "undoDepth" property for details..SH "void QTextEdit::setUndoRedoEnabled ( bool b )\fC [virtual slot]\fR"Sets whether undo/redo is enabled to \fIb\fR. See the "undoRedoEnabled" property for details..SH "void QTextEdit::setVerticalAlignment ( VerticalAlignment a )\fC [virtual slot]\fR"Sets the vertical alignment of the current format, i.e. of the text, to \fIa\fR..PPSee also color() and paper..SH "void QTextEdit::setWordWrap ( WordWrap mode )\fC [virtual slot]\fR"Sets the word wrap mode to \fImode\fR. See the "wordWrap" property for details..SH "void QTextEdit::setWrapColumnOrWidth ( int )\fC [virtual slot]\fR"Sets the position (in pixels or columns depending on the wrap mode) where text will be wrapped. See the "wrapColumnOrWidth" property for details..SH "void QTextEdit::setWrapPolicy ( WrapPolicy policy )\fC [virtual slot]\fR"Sets the word wrap policy, at whitespace or anywhere to \fIpolicy\fR. See the "wrapPolicy" property for details..SH "QStyleSheet * QTextEdit::styleSheet () const"Returns the QStyleSheet which is being used by this text edit..PPSee also setStyleSheet()..PPExample: helpviewer/helpwindow.cpp..SH "void QTextEdit::sync ()\fC [virtual slot]\fR"QTextEdit is optimized for large amounts text. One of its optimizations is to format only the visible text, formatting the rest on demand, e.g. as the user scrolls, so you don't usually need to call this function..PPIn some situations you may want to force the whole text to be formatted. For example, if after calling setText(), you wanted to know the height of the document (using contentsHeight()), you would call this function first..SH "bool QTextEdit::tabChangesFocus () const"Returns TRUE if TAB changes focus or is accepted as input; otherwise returns FALSE. See the "tabChangesFocus" property for details..SH "int QTextEdit::tabStopWidth () const"Returns the tab stop width in pixels. See the "tabStopWidth" property for details..SH "QString QTextEdit::text () const"Returns the text edit's text. See the "text" property for details..SH "QString QTextEdit::text ( int para ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the text of paragraph \fIpara\fR..PPIf textFormat() is RichText the text will contain HTML formatting tags..SH "void QTextEdit::textChanged ()\fC [signal]\fR"This signal is emitted whenever the text in the text edit changes..PPSee also text and append()..PPExamples:.)l qwerty/qwerty.cpp and rot13/rot13.cpp..SH "QTextCursor * QTextEdit::textCursor () const\fC [protected]\fR"Returns the text edit's text cursor..PP\fBWarning:\fR QTextCursor is not in the public API, but in special circumstances you might wish to use it..SH "TextFormat QTextEdit::textFormat () const"Returns the text format: rich text, plain text, log text or auto text. See the "textFormat" property for details..SH "bool QTextEdit::underline () const"Returns TRUE if the current format is underlined; otherwise returns FALSE..PPSee also setUnderline()..SH "void QTextEdit::undo ()\fC [virtual slot]\fR"Undoes the last operation..PPIf there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens..PPSee also undoAvailable(), redo(), and undoDepth..SH "void QTextEdit::undoAvailable ( bool yes )\fC [signal]\fR"This signal is emitted when the availability of undo changes. If \fIyes\fR is TRUE, then undo() will work until undoAvailable( FALSE ) is next emitted..PPSee also undo() and undoDepth..SH "int QTextEdit::undoDepth () const"Returns the depth of the undo history. See the "undoDepth" property for details..SH "WordWrap QTextEdit::wordWrap () const"Returns the word wrap mode. See the "wordWrap" property for details..SH "int QTextEdit::wrapColumnOrWidth () const"Returns the position (in pixels or columns depending on the wrap mode) where text will be wrapped. See the "wrapColumnOrWidth" property for details..SH "WrapPolicy QTextEdit::wrapPolicy () const"Returns the word wrap policy, at whitespace or anywhere. See the "wrapPolicy" property for details..SH "void QTextEdit::zoomIn ( int range )\fC [virtual slot]\fR"Zooms in on the text by by making the base font size \fIrange\fR points larger and recalculating all font sizes. This does not change the size of any images..PPSee also zoomOut()..SH "void QTextEdit::zoomIn ()\fC [virtual slot]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPZooms in on the text by by making the base font size one point larger and recalculating all font sizes. This does not change the size of any images..PPSee also zoomOut()..SH "void QTextEdit::zoomOut ( int range )\fC [virtual slot]\fR"Zooms out on the text by making the base font size \fIrange\fR points smaller and recalculating all font sizes. This does not change the size of any images..PPSee also zoomIn()..SH "void QTextEdit::zoomOut ()\fC [virtual slot]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPZooms out on the text by by making the base font size one point smaller and recalculating all font sizes. This does not change the size of any images..PPSee also zoomIn()..SH "void QTextEdit::zoomTo ( int size )\fC [virtual slot]\fR"Zooms the text by making the base font size \fIsize\fR points and recalculating all font sizes. This does not change the size of any images..SS "Property Documentation".SH "QString documentTitle"This property holds the title of the document parsed from the text..PPFor PlainText the title will be an empty string. For RichText the title will be the text between the \fC<title>\fR tags, if present, otherwise an empty string..PPGet this property's value with documentTitle()..SH "bool hasSelectedText"This property holds whether some text is selected in selection 0..PPGet this property's value with hasSelectedText()..SH "int length"This property holds the number of characters in the text..PPGet this property's value with length()..
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -