返回介绍

QMultiLineEdit Class

发布于 2019-10-04 15:01:44 字数 14782 浏览 902 评论 0 收藏 0

The QMultiLineEdit widget is a simple editor for inputting text. More...

#include <qmultilineedit.h>

Inherits QTextEdit.

List of all member functions.

Public Members

  • QMultiLineEdit ( QWidget*parent = 0, constchar*name = 0 )
  • QString textLine ( intline ) const
  • int numLines () const
  • virtual void insertLine ( constQString&txt, intline = -1 )
  • virtual void insertAt ( constQString&s, intline, intcol, boolmark = FALSE )
  • virtual void removeLine ( intparagraph )
  • virtual void setCursorPosition ( intline, intcol, boolmark = FALSE )
  • bool atBeginning () const
  • bool atEnd () const
  • virtual void setAlignment ( intflags )
  • int alignment () const
  • void setEdited ( bool )
  • bool edited () const
  • bool hasMarkedText () const
  • QString markedText () const
  • void cursorWordForward ( boolmark )
  • void cursorWordBackward ( boolmark )
  • bool autoUpdate () const (obsolete)
  • virtual void setAutoUpdate ( bool ) (obsolete)
  • int totalWidth () const (obsolete)
  • int totalHeight () const (obsolete)
  • int maxLines () const (obsolete)
  • void setMaxLines ( int ) (obsolete)

Public Slots

  • void deselect () (obsolete)

Properties

  • Alignment alignment- the editor's paragraph alignment
  • bool atBeginning- whether the cursor is placed at the beginning of the text (read only)
  • bool atEnd- whether the cursor is placed at the end of the text (read only)
  • bool edited- whether the document has been edited by the user
  • int numLines- the number of paragraphs in the editor (read only)

Protected Members

  • QPoint cursorPoint () const
  • virtual void insertAndMark ( constQString&str, boolmark )
  • virtual void newLine ()
  • virtual void killLine ()
  • virtual void pageUp ( boolmark = FALSE )
  • virtual void pageDown ( boolmark = FALSE )
  • virtual void cursorLeft ( boolmark = FALSE, boolwrap = TRUE )
  • virtual void cursorRight ( boolmark = FALSE, boolwrap = TRUE )
  • virtual void cursorUp ( boolmark = FALSE )
  • virtual void cursorDown ( boolmark = FALSE )
  • virtual void backspace ()
  • virtual void home ( boolmark = FALSE )
  • virtual void end ( boolmark = FALSE )
  • bool getMarkedRegion ( int*line1, int*col1, int*line2, int*col2 ) const
  • int lineLength ( introw ) const

Detailed Description

This class is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

The QMultiLineEdit widget is a simple editor for inputting text.

The QMultiLineEdit was a simple editor widget in former Qt versions. Qt 3.0 includes a new richtext engine which obsoletes QMultiLineEdit. It is still included for compatibility reasons. It is now a subclass of QTextEdit, and provides enough of the old QMultiLineEdit API to keep old applications working.

If you implement something new with QMultiLineEdit, we suggest using QTextEdit instead and call QTextEdit::setTextFormat(Qt::PlainText).

Although most of the old QMultiLineEdit API is still available, there is a few difference. The old QMultiLineEdit operated on lines, not on paragraphs. As lines change all the time during wordwrap, the new richtext engine uses paragraphs as basic elements in the data structure. All functions (numLines(), textLine(), etc.) that operated on lines, now operate on paragraphs. Further, getString() has been removed completely. It revealed too much of the internal data structure.

Applications which made normal and reasonable use of QMultiLineEdit should still work without problems. Some odd usage will require some porting. In these cases, it may be better to use QTextEdit now.

See also QTextEdit and Advanced Widgets.


Member Function Documentation

QMultiLineEdit::QMultiLineEdit ( QWidget*parent = 0, constchar*name = 0 )

Constructs a new, empty, QMultiLineEdit with parent parent called name.

int QMultiLineEdit::alignment () const

Returns the editor's paragraph alignment. See the "alignment" property for details.

bool QMultiLineEdit::atBeginning () const

Returns TRUE if the cursor is placed at the beginning of the text; otherwise returns FALSE. See the "atBeginning" property for details.

bool QMultiLineEdit::atEnd () const

Returns TRUE if the cursor is placed at the end of the text; otherwise returns FALSE. See the "atEnd" property for details.

bool QMultiLineEdit::autoUpdate () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void QMultiLineEdit::backspace () [virtual protected]

Deletes the character on the left side of the text cursor and moves the cursor one position to the left. If a text has been selected by the user (e.g. by clicking and dragging) the cursor is put at the beginning of the selected text and the selected text is removed. del()

void QMultiLineEdit::cursorDown ( boolmark = FALSE ) [virtual protected]

Moves the cursor one line down. If mark is TRUE, the text is selected.

See also cursorUp(), cursorLeft() and cursorRight().

void QMultiLineEdit::cursorLeft ( boolmark = FALSE, boolwrap = TRUE ) [virtual protected]

Moves the cursor one character to the left. If mark is TRUE, the text is selected. The wrap parameter is currently ignored.

See also cursorRight(), cursorUp() and cursorDown().

QPoint QMultiLineEdit::cursorPoint () const [protected]

Returns the top center point where the cursor is drawn.

void QMultiLineEdit::cursorRight ( boolmark = FALSE, boolwrap = TRUE ) [virtual protected]

Moves the cursor one character to the right. If mark is TRUE, the text is selected. The wrap parameter is currently ignored.

See also cursorLeft(), cursorUp() and cursorDown().

void QMultiLineEdit::cursorUp ( boolmark = FALSE ) [virtual protected]

Moves the cursor up one line. If mark is TRUE, the text is selected.

See also cursorDown(), cursorLeft() and cursorRight().

void QMultiLineEdit::cursorWordBackward ( boolmark )

Moves the cursor one word to the left. If mark is TRUE, the text is selected.

See also cursorWordForward().

void QMultiLineEdit::cursorWordForward ( boolmark )

Moves the cursor one word to the right. If mark is TRUE, the text is selected.

See also cursorWordBackward().

void QMultiLineEdit::deselect () [slot]

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

bool QMultiLineEdit::edited () const

Returns TRUE if the document has been edited by the user; otherwise returns FALSE. See the "edited" property for details.

void QMultiLineEdit::end ( boolmark = FALSE ) [virtual protected]

Moves the text cursor to the right end of the line. If mark is TRUE, text is selected toward the last position. If it is FALSE and the cursor is moved, all selected text is unselected.

See also home().

bool QMultiLineEdit::getMarkedRegion ( int*line1, int*col1, int*line2, int*col2 ) const [protected]

If there is selected text, sets line1, col1, line2 and col2 to the start and end of the selected region and returns TRUE. Returns FALSE if there is no selected text.

bool QMultiLineEdit::hasMarkedText () const

Returns TRUE if there is selected text.

void QMultiLineEdit::home ( boolmark = FALSE ) [virtual protected]

Moves the text cursor to the left end of the line. If mark is TRUE, text is selected toward the first position. If it is FALSE and the cursor is moved, all selected text is unselected.

See also end().

void QMultiLineEdit::insertAndMark ( constQString&str, boolmark ) [virtual protected]

Inserts str at the current cursor position and selects the text if mark is TRUE.

void QMultiLineEdit::insertAt ( constQString&s, intline, intcol, boolmark = FALSE ) [virtual]

Inserts string s at paragraph number line, after character number col in the paragraph. If s contains newline characters, new lines are inserted. If mark is TRUE the inserted string will be selected.

The cursor position is adjusted.

void QMultiLineEdit::insertLine ( constQString&txt, intline = -1 ) [virtual]

Inserts txt at paragraph number line. If line is less than zero, or larger than the number of paragraphs, the new text is put at the end. If txt contains newline characters, several paragraphs are inserted.

The cursor position is not changed.

void QMultiLineEdit::killLine () [virtual protected]

Deletes text from the current cursor position to the end of the line. (Note that this function still operates on lines, not paragraphs.)

int QMultiLineEdit::lineLength ( introw ) const [protected]

Returns the number of characters at paragraph number row. If row is out of range, -1 is returned.

QString QMultiLineEdit::markedText () const

Returns a copy of the selected text.

int QMultiLineEdit::maxLines () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

void QMultiLineEdit::newLine () [virtual protected]

Splits the paragraph at the current cursor position.

int QMultiLineEdit::numLines () const

Returns the number of paragraphs in the editor. See the "numLines" property for details.

void QMultiLineEdit::pageDown ( boolmark = FALSE ) [virtual protected]

Moves the cursor one page down. If mark is TRUE, the text is selected.

void QMultiLineEdit::pageUp ( boolmark = FALSE ) [virtual protected]

Moves the cursor one page up. If mark is TRUE, the text is selected.

void QMultiLineEdit::removeLine ( intparagraph ) [virtual]

Deletes the paragraph at paragraph number paragraph. If paragraph is less than zero or larger than the number of paragraphs, nothing is deleted.

void QMultiLineEdit::setAlignment ( intflags ) [virtual]

Sets the editor's paragraph alignment to flags. See the "alignment" property for details.

Reimplemented from QTextEdit.

void QMultiLineEdit::setAutoUpdate ( bool ) [virtual]

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Example: qwerty/qwerty.cpp.

void QMultiLineEdit::setCursorPosition ( intline, intcol, boolmark = FALSE ) [virtual]

Sets the cursor position to character number col in paragraph number line. The parameters are adjusted to lie within the legal range.

If mark is FALSE, the selection is cleared. otherwise it is extended.

void QMultiLineEdit::setEdited ( bool )

Sets whether the document has been edited by the user. See the "edited" property for details.

void QMultiLineEdit::setMaxLines ( int )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

QString QMultiLineEdit::textLine ( intline ) const

Returns the text at line number line (possibly the empty string), or a null string if line is invalid.

Examples: mdi/application.cpp and qwerty/qwerty.cpp.

int QMultiLineEdit::totalHeight () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

int QMultiLineEdit::totalWidth () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.


Property Documentation

Alignment alignment

This property holds the editor's paragraph alignment.

Sets the alignment to flag, which must be AlignLeft, AlignHCenter or AlignRight.

If flag is an illegal flag nothing happens.

See also Qt::AlignmentFlags.

Set this property's value with setAlignment() and get this property's value with alignment().

bool atBeginning

This property holds whether the cursor is placed at the beginning of the text.

Get this property's value with atBeginning().

See also atEnd.

bool atEnd

This property holds whether the cursor is placed at the end of the text.

Get this property's value with atEnd().

See also atBeginning.

bool edited

This property holds whether the document has been edited by the user.

This is the same as QTextEdit's "modifed" property.

See also QTextEdit::modified.

Set this property's value with setEdited() and get this property's value with edited().

int numLines

This property holds the number of paragraphs in the editor.

The count includes any empty paragraph at top and bottom, so for an empty editor this method returns 1.

Get this property's value with numLines().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文