The Q3MultiLineEdit widget is a simple editor for inputting text. 更多...
| 头: | #include <Q3MultiLineEdit> |
| 继承: | Q3TextEdit |
|
| Q3MultiLineEdit (QWidget * parent = 0, const char * name = 0) | |
| ~Q3MultiLineEdit () | |
| Qt::Alignment | alignment () const |
| bool | atBeginning () const |
| bool | atEnd () const |
| bool | autoUpdate () const |
| void | cursorWordBackward (bool mark ) |
| void | cursorWordForward (bool mark ) |
| bool | edited () const |
| bool | hasMarkedText () const |
| virtual void | insertAt (const QString & s , int line , int col , bool mark ) |
| virtual void | insertLine (const QString & txt , int line = -1) |
| QString | markedText () const |
| int | maxLines () const |
| int | numLines () const |
| virtual void | removeLine (int paragraph ) |
| void | setAlignment (Qt::Alignment flags ) |
| virtual void | setCursorPosition (int line , int col , bool mark ) |
| void | setEdited (bool) |
| void | setMaxLines (int max ) |
| QString | textLine (int line ) const |
| int | totalHeight () const |
| int | totalWidth () const |
| virtual void | insertAt (const QString & s , int line , int col ) |
| virtual void | setCursorPosition (int line , int col ) |
| void | deselect () |
| virtual void | backspace () |
| virtual void | cursorDown (bool mark = false) |
| virtual void | cursorLeft (bool mark = false, bool wrap = true) |
| QPoint | cursorPoint () const |
| virtual void | cursorRight (bool mark = false, bool wrap = true) |
| virtual void | cursorUp (bool mark = false) |
| virtual void | end (bool mark = false) |
| bool | getMarkedRegion (int * line1 , int * col1 , int * line2 , int * col2 ) const |
| virtual void | home (bool mark = false) |
| virtual void | insertAndMark (const QString & str , bool mark ) |
| virtual void | killLine () |
| int | lineLength (int row ) const |
| virtual void | newLine () |
| virtual void | pageDown (bool mark = false) |
| virtual void | pageUp (bool mark = false) |
The Q3MultiLineEdit widget is a simple editor for inputting text.
The Q3MultiLineEdit was a simple editor widget in former Qt versions. Qt 3.0 includes a new richtext engine which obsoletes Q3MultiLineEdit . It is still included for compatibility reasons. It is now a subclass of Q3TextEdit , and provides enough of the old Q3MultiLineEdit API to keep old applications working.
If you implement something new with Q3MultiLineEdit , we suggest using Q3TextEdit instead and call Q3TextEdit::setTextFormat ( Qt::PlainText ).
Although most of the old Q3MultiLineEdit API is still available, there is a few difference. The old Q3MultiLineEdit 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 Q3MultiLineEdit should still work without problems. Some odd usage will require some porting. In these cases, it may be better to use Q3TextEdit now.
另请参阅 Q3TextEdit .
This property holds the editor's paragraph alignment.
Sets the alignment to flag, which must be
Qt::AlignLeft
,
Qt::AlignHCenter
,或
Qt::AlignRight
.
If flag is an illegal flag, nothing happens.
访问函数:
| Qt::Alignment | alignment () const |
| void | setAlignment (Qt::Alignment flags ) |
This property holds whether the cursor is placed at the beginning of the text.
访问函数:
| bool | atBeginning () const |
另请参阅 atEnd .
This property holds whether the cursor is placed at the end of the text.
访问函数:
| bool | atEnd () const |
另请参阅 atBeginning .
This property holds whether the document has been edited by the user.
这如同 Q3TextEdit 's "modifed" property.
访问函数:
| bool | edited () const |
| void | setEdited (bool) |
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.
访问函数:
| int | numLines () const |
Constructs a new, empty, Q3MultiLineEdit 采用父级 parent called name .
析构函数。
This function is a noop that always returns true.
[virtual protected]
void
Q3MultiLineEdit::
backspace
()
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 ()
[virtual protected]
void
Q3MultiLineEdit::
cursorDown
(
bool
mark
= false)
Moves the cursor one line down. If mark is true, the text is selected.
另请参阅 cursorUp (), cursorLeft (),和 cursorRight ().
[virtual protected]
void
Q3MultiLineEdit::
cursorLeft
(
bool
mark
= false,
bool
wrap
= true)
Moves the cursor one character to the left. If mark is true, the text is selected. The wrap parameter is currently ignored.
另请参阅 cursorRight (), cursorUp (),和 cursorDown ().
[protected]
QPoint
Q3MultiLineEdit::
cursorPoint
() const
Returns the top center point where the cursor is drawn.
[virtual protected]
void
Q3MultiLineEdit::
cursorRight
(
bool
mark
= false,
bool
wrap
= true)
Moves the cursor one character to the right. If mark is true, the text is selected. The wrap parameter is currently ignored.
另请参阅 cursorLeft (), cursorUp (),和 cursorDown ().
[virtual protected]
void
Q3MultiLineEdit::
cursorUp
(
bool
mark
= false)
Moves the cursor up one line. If mark is true, the text is selected.
另请参阅 cursorDown (), cursorLeft (),和 cursorRight ().
Moves the cursor one word to the left. If mark is true, the text is selected.
另请参阅 cursorWordForward ().
Moves the cursor one word to the right. If mark is true, the text is selected.
另请参阅 cursorWordBackward ().
[slot]
void
Q3MultiLineEdit::
deselect
()
[virtual protected]
void
Q3MultiLineEdit::
end
(
bool
mark
= false)
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.
另请参阅 home ().
[protected]
bool
Q3MultiLineEdit::
getMarkedRegion
(
int
*
line1
,
int
*
col1
,
int
*
line2
,
int
*
col2
) const
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.
Returns true if there is selected text.
[virtual protected]
void
Q3MultiLineEdit::
home
(
bool
mark
= false)
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.
另请参阅 end ().
[virtual protected]
void
Q3MultiLineEdit::
insertAndMark
(const
QString
&
str
,
bool
mark
)
插入 str at the current cursor position and selects the text if mark 为 true。
[虚拟]
void
Q3MultiLineEdit::
insertAt
(const
QString
&
s
,
int
line
,
int
col
)
重实现自 Q3TextEdit::insertAt ().
[虚拟]
void
Q3MultiLineEdit::
insertAt
(const
QString
&
s
,
int
line
,
int
col
,
bool
mark
)
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
Q3MultiLineEdit::
insertLine
(const
QString
&
txt
,
int
line
= -1)
插入 txt at paragraph number line 。若 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.
[virtual protected]
void
Q3MultiLineEdit::
killLine
()
Deletes text from the current cursor position to the end of the line. (Note that this function still operates on lines, not paragraphs.)
[protected]
int
Q3MultiLineEdit::
lineLength
(
int
row
) const
Returns the number of characters at paragraph number row 。若 row is out of range, -1 is returned.
Returns a copy of the selected text.
另请参阅 setMaxLines ().
[virtual protected]
void
Q3MultiLineEdit::
newLine
()
Splits the paragraph at the current cursor position.
[virtual protected]
void
Q3MultiLineEdit::
pageDown
(
bool
mark
= false)
Moves the cursor one page down. If mark is true, the text is selected.
[virtual protected]
void
Q3MultiLineEdit::
pageUp
(
bool
mark
= false)
Moves the cursor one page up. If mark is true, the text is selected.
[虚拟]
void
Q3MultiLineEdit::
removeLine
(
int
paragraph
)
Deletes the paragraph at paragraph number paragraph 。若 paragraph is less than zero or larger than the number of paragraphs, nothing is deleted.
[虚拟]
void
Q3MultiLineEdit::
setCursorPosition
(
int
line
,
int
col
)
重实现自 Q3TextEdit::setCursorPosition ().
[虚拟]
void
Q3MultiLineEdit::
setCursorPosition
(
int
line
,
int
col
,
bool
mark
)
Sets the cursor position to character number col in paragraph number line . The parameters are adjusted to lie within the legal range.
若 mark is false, the selection is cleared. otherwise it is extended.
Sets the maximum number of lines this Q3MultiLineEdit will hold to max .
另请参阅 maxLines ().
Returns the text at line number line (possibly the empty string), or a null if line 无效。