Wiki Markup |
---|
{alias:qtextedit} |
Name
qtextedit — multiline text editor
...
The qtextedit command creates a QTextEdit object. This is a multiline text editor in which the user may edit text interactively or programmatically. To set the contents of the editor use the qsettext command. To append text use qappend. To retrieve the text use qtext. The editor contents may be cleared using qclear.
Arguments
None
Examples
Ex.1: QTextEdit
...
No Format | ||||
---|---|---|---|---|
| ||||
# Create toplevel window
set w [qwidget ]
qsetwindowtitle QTextEdit
# Create editor and insert/retrieve text
qvboxlayout {
set editor [qtextedit]
qsettext $editor "Hello World"
qappend $editor "Appending text is easy"
# Get text and assign to Tcl variable
set text [qtext $editor]
puts $text
}
qshow $w
|
...
Example QTextEdit shows a QTextEdit with text added using the qsettext and qappend commands.
Ex.2: Editor with clear button
...
No Format | ||||
---|---|---|---|---|
| ||||
set w [qwidget]
qsetwindowtitle "Editor"
qvboxlayout {
set editor [qtextedit]
qpushbutton Clear "qclear $editor"
}
qshow $w
|
...
Example Editor with clear button illustrates use of the qclear command. Pressing the Clear button will clear the textual contents of the editor.