QTextEdit窗口部件提供了强大的单页面的多信息文本编辑器。
详情请见……
#include
继承了QScrollView。
被QMultiLineEdit、QTextBrowser和QTextView继承。
所有成员函数的列表。
公有成员
enum WordWrap { NoWrap, WidgetWidth, FixedPixelWidth, FixedColumnWidth }
enum WrapPolicy { AtWordBoundary, Anywhere, AtWhiteSpace = AtWordBoundary }
enum KeyboardAction { ActionBackspace, ActionDelete, ActionReturn, ActionKill }
enum CursorAction { MoveBackward, MoveForward, MoveWordBackward, MoveWordForward, MoveUp, MoveDown, MoveLineStart, MoveLineEnd, MoveHome, MoveEnd, MovePgUp, MovePgDown }
enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }
QTextEdit ( constQString&text, constQString&context = QString::null, QWidget*parent = 0, constchar*name = 0 )
QTextEdit ( QWidget*parent = 0, constchar*name = 0 )
QString text () const
QString text ( intpara ) const
TextFormat textFormat () const
QString context () const
QString documentTitle () const
void getSelection ( int*paraFrom, int*indexFrom, int*paraTo, int*indexTo, intselNum = 0 ) const
virtual bool find ( constQString&expr, boolcs, boolwo, boolforward = TRUE, int*para = 0, int*index = 0 )
int paragraphs () const
int lines () const
int linesOfParagraph ( intpara ) const
int lineOfChar ( intpara, intindex )
int length () const
QRect paragraphRect ( intpara ) const
int paragraphAt ( constQPoint&pos ) const
int charAt ( constQPoint&pos, int*para ) const
int paragraphLength ( intpara ) const
QStyleSheet * styleSheet () const
QMimeSourceFactory * mimeSourceFactory () const
QBrush paper () const
bool linkUnderline () const
virtual int heightForWidth ( intw ) const
bool hasSelectedText () const
QString selectedText () const
bool isUndoAvailable () const
bool isRedoAvailable () const
WordWrap wordWrap () const
int wrapColumnOrWidth () const
WrapPolicy wrapPolicy () const
int tabStopWidth () const
QString anchorAt ( constQPoint&pos )
bool isReadOnly () const
void getCursorPosition ( int*para, int*index ) const
bool isModified () const
bool italic () const
bool bold () const
bool underline () const
QString family () const
int pointSize () const
QColor color () const
QFont font () const
int alignment () const
int undoDepth () const
bool isOverwriteMode () const
QColor paragraphBackgroundColor ( intpara ) const
bool isUndoRedoEnabled () const
公有槽
virtual void setMimeSourceFactory ( QMimeSourceFactory*factory )
virtual void setStyleSheet ( QStyleSheet*styleSheet )
virtual void scrollToAnchor ( constQString&name )
virtual void setPaper ( constQBrush&pap )
virtual void setLinkUnderline ( bool )
virtual void setWordWrap ( WordWrapmode )
virtual void setWrapColumnOrWidth ( int )
virtual void setWrapPolicy ( WrapPolicypolicy )
virtual void copy ()
virtual void append ( constQString&text )
void setText ( constQString&txt )
virtual void setText ( constQString&text, constQString&context )
virtual void setTextFormat ( TextFormatf )
virtual void selectAll ( boolselect = TRUE )
virtual void setTabStopWidth ( intts )
virtual void zoomIn ( intrange )
virtual void zoomIn ()
virtual void zoomOut ( intrange )
virtual void zoomOut ()
virtual void zoomTo ( intsize )
virtual void setReadOnly ( boolb )
virtual void undo ()
virtual void redo ()
virtual void cut ()
virtual void paste ()
virtual void pasteSubType ( constQCString&subtype )
virtual void clear ()
virtual void del ()
virtual void indent ()
virtual void setItalic ( boolb )
virtual void setBold ( boolb )
virtual void setUnderline ( boolb )
virtual void setFamily ( constQString&fontFamily )
virtual void setPointSize ( ints )
virtual void setColor ( constQColor&c )
virtual void setVerticalAlignment ( VerticalAlignmenta )
virtual void setAlignment ( inta )
virtual void setCursorPosition ( intpara, intindex )
virtual void setSelection ( intparaFrom, intindexFrom, intparaTo, intindexTo, intselNum = 0 )
virtual void setSelectionAttributes ( intselNum, constQColor&back, boolinvertText )
virtual void setModified ( boolm )
virtual void setUndoDepth ( intd )
virtual void ensureCursorVisible ()
virtual void placeCursor ( constQPoint&pos, QTextCursor*c = 0 )
virtual void moveCursor ( CursorActionaction, boolselect )
virtual void doKeyboardAction ( KeyboardActionaction )
virtual void removeSelectedText ( intselNum = 0 )
virtual void removeSelection ( intselNum = 0 )
virtual void setCurrentFont ( constQFont&f )
virtual void setOverwriteMode ( boolb )
virtual void scrollToBottom ()
virtual void insert ( constQString&text, boolindent = FALSE, boolcheckNewLine = TRUE, boolremoveSelected = TRUE )
virtual void insertAt ( constQString&text, intpara, intindex )
virtual void removeParagraph ( intpara )
virtual void insertParagraph ( constQString&text, intpara )
virtual void setParagraphBackgroundColor ( intpara, constQColor&bg )
virtual void clearParagraphBackground ( intpara )
virtual void setUndoRedoEnabled ( boolb )
信号
void textChanged ()
void selectionChanged ()
void copyAvailable ( boolyes )
void undoAvailable ( boolyes )
void redoAvailable ( boolyes )
void currentFontChanged ( constQFont&f )
void currentColorChanged ( constQColor&c )
void currentAlignmentChanged ( inta )
void currentVerticalAlignmentChanged ( VerticalAlignmenta )
void cursorPositionChanged ( QTextCursor*c )
void cursorPositionChanged ( intpara, intpos )
void returnPressed ()
void modificationChanged ( boolm )
属性
QString documentTitle– 从文本中分析出的文档标题(只读)
bool hasSelectedText– 是否有文本被选择到选择区0中(只读)
int length– 文本的字符数(只读)
bool linkUnderline– 超文本链接是否使用下划线
bool modified– 文档是否已经被用户修改
bool overwriteMode– 文本编辑的覆盖模式
QBrush paper– 背景(纸)的画刷
bool readOnly– 文本编辑是否只读
QString selectedText– 被选择的文本(在选择区0中)或者如果当前没有被选择的文本(在选择区0中)就是空字符串(只读)
int tabStopWidth– tab stop的象素宽度s
QString text– 文本编辑的文本
TextFormat textFormat– 文本格式:多信息文本、一般文本或者自动文本
int undoDepth– 撤销历史的深度
bool undoRedoEnabled– 撤销/恢复是否生效
WordWrap wordWrap– 自动换行模式
int wrapColumnOrWidth– 被自动换行的文本的位置(根据自动换行模式来决定是像素还是列)
WrapPolicy wrapPolicy– 自动换行策略,在空白符号还是在任何地方
保护成员
void repaintChanged ()
virtual void keyPressEvent ( QKeyEvent*e )
virtual bool focusNextPrevChild ( booln )
QTextCursor * textCursor () const
virtual QPopupMenu * createPopupMenu ( constQPoint&pos )
virtual QPopupMenu * createPopupMenu () (obsolete)
详细描述
QTextEdit窗口部件提供了强大的单页面的多信息文本编辑器。
介绍和概念
使用QTextEdit作为一个显示窗口部件
只读的键绑定
使用QTextEdit作为一个编辑器
编辑键绑定
介绍和概念
QTextEdit是一个高级的所见即所得的支持使用HTML风格标记的多信息文本格式的查看器/编辑器。它对于处理大文档和快速相应用户的输入进行了优化。
QTextEdit操作的三个模式:
模式命令注释
一般文本编辑器setTextFormat(PlainText)使用setText()设置文本