Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
doc_src_richtext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QTextDocument>
4#include <QTextEdit>
5
6namespace doc_src_richtext {
7
8void wrapper() {
9//! [0]
10QTextDocument *newDocument = new QTextDocument;
11//! [0]
12
13
14//! [1]
15QTextEdit *editor = new QTextEdit;
16QTextDocument *editorDocument = editor->document();
17//! [1]
18Q_UNUSED(newDocument);
19Q_UNUSED(editorDocument);
20} // wrapper
21
22void wrapper2() {
23auto parent = new QTextEdit();
24QString aStringContainingHTMLtext;
25//! [2]
26QTextEdit *editor = new QTextEdit(parent);
27editor->setHtml(aStringContainingHTMLtext);
28editor->show();
29//! [2]
30
31
32//! [3]
33QTextDocument *document = editor->document();
34//! [3]
35Q_UNUSED(document);
36
37//! [4]
38QTextCursor cursor = editor->textCursor();
39//! [4]
40
41
42//! [5]
43editor->setTextCursor(cursor);
44//! [5]
45
46
47QTextEdit textEdit;
48QTextCursor textCursor;
49QString paragraphText;
50//! [6]
51textEdit.show();
52
53textCursor.beginEditBlock();
54
55for (int i = 0; i < 1000; ++i) {
56 textCursor.insertBlock();
57 textCursor.insertText(paragraphText.at(i));
58}
59
60textCursor.endEditBlock();
61//! [6]
62
63} // wrapper2
64} // doc_src_richtext