| 1 |
# QTextEdit |
| 2 |
|
| 3 |
The QTextEdit widget is an advanced editor that supports formatted rich text. |
| 4 |
It can be used to display HTML and other rich document formats. Internally, |
| 5 |
QTextEdit uses the QTextDocument class to describe both the high-level |
| 6 |
structure of each document and the low-level formatting of paragraphs. |
| 7 |
|
| 8 |
If you are viewing this document in the textedit example, you can edit this |
| 9 |
document to explore Qt's rich text editing features. We have included some |
| 10 |
comments in each of the following sections to encourage you to experiment. |
| 11 |
|
| 12 |
## Font and Paragraph Styles |
| 13 |
|
| 14 |
QTextEdit supports **bold**, *italic*, and ~~strikethrough~~ font styles, and can |
| 15 |
display multicolored text. Font families such as Times New Roman and `Courier` |
| 16 |
can also be used directly. *If you place the cursor in a region of styled text, |
| 17 |
the controls in the tool bars will change to reflect the current style.* |
| 18 |
|
| 19 |
Paragraphs can be formatted so that the text is left-aligned, right-aligned, |
| 20 |
centered, or fully justified. |
| 21 |
|
| 22 |
*Try changing the alignment of some text and resize the editor to see how the |
| 23 |
text layout changes.* |
| 24 |
|
| 25 |
## Lists |
| 26 |
|
| 27 |
Different kinds of lists can be included in rich text documents. Standard |
| 28 |
bullet lists can be nested, using different symbols for each level of the list: |
| 29 |
|
| 30 |
- Disc symbols are typically used for top-level list items. |
| 31 |
* Circle symbols can be used to distinguish between items in lower-level |
| 32 |
lists. |
| 33 |
+ Square symbols provide a reasonable alternative to discs and circles. |
| 34 |
|
| 35 |
Ordered lists can be created that can be used for tables of contents. Different |
| 36 |
characters can be used to enumerate items, and we can use both Roman and Arabic |
| 37 |
numerals in the same list structure: |
| 38 |
|
| 39 |
1. Introduction |
| 40 |
2. Qt Tools |
| 41 |
1) Qt Assistant |
| 42 |
2) Qt Designer |
| 43 |
1. Form Editor |
| 44 |
2. Component Architecture |
| 45 |
3) Qt Linguist |
| 46 |
|
| 47 |
The list will automatically be renumbered if you add or remove items. *Try |
| 48 |
adding new sections to the above list or removing existing item to see the |
| 49 |
numbers change.* |
| 50 |
|
| 51 |
## Images |
| 52 |
|
| 53 |
Inline images are treated like ordinary ranges of characters in the text |
| 54 |
editor, so they flow with the surrounding text. Images can also be selected in |
| 55 |
the same way as text, making it easy to cut, copy, and paste them. |
| 56 |
|
| 57 |
 *Try to select this image by clicking and dragging |
| 58 |
over it with the mouse, or use the text cursor to select it by holding down |
| 59 |
Shift and using the arrow keys. You can then cut or copy it, and paste it into |
| 60 |
different parts of this document.* |
| 61 |
|
| 62 |
## Tables |
| 63 |
|
| 64 |
QTextEdit can arrange and format tables, supporting features such as row and |
| 65 |
column spans, text formatting within cells, and size constraints for columns. |
| 66 |
|
| 67 |
|
| 68 |
| |Development Tools |Programming Techniques |Graphical User Interfaces| |
| 69 |
|-------------|------------------------------------|---------------------------|-------------------------| |
| 70 |
|9:00 - 11:00 |Introduction to Qt ||| |
| 71 |
|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt | |
| 72 |
|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles | |
| 73 |
|15:00 - 17:00|Qt Linguist and Internationalization| | | |
| 74 |
|
| 75 |
*Try adding text to the cells in the table and experiment with the alignment of |
| 76 |
the paragraphs.* |
| 77 |
|
| 78 |
## Hyperlinks |
| 79 |
|
| 80 |
QTextEdit is designed to support hyperlinks between documents, and this feature |
| 81 |
is used extensively in |
| 82 |
[Qt Assistant](http://doc.qt.io/qt-5/qtassistant-index.html). Hyperlinks are |
| 83 |
automatically created when an HTML file is imported into an editor. Since the |
| 84 |
rich text framework supports hyperlinks natively, they can also be created |
| 85 |
programatically. |
| 86 |
|
| 87 |
## Undo and Redo |
| 88 |
|
| 89 |
Full support for undo and redo operations is built into QTextEdit and the |
| 90 |
underlying rich text framework. Operations on a document can be packaged |
| 91 |
together to make editing a more comfortable experience for the user. |
| 92 |
|
| 93 |
*Try making changes to this document and press `Ctrl+Z` to undo them. You can |
| 94 |
always recover the original contents of the document.* |
| 95 |
|