Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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() {
10QTextDocument *newDocument = new QTextDocument;
12
13
15QTextEdit *editor = new QTextEdit;
16QTextDocument *editorDocument = editor->document();
18Q_UNUSED(newDocument);
19Q_UNUSED(editorDocument);
20} // wrapper
21
22void wrapper2() {
23auto parent = new QTextEdit();
24QString aStringContainingHTMLtext;
26QTextEdit *editor = new QTextEdit(parent);
27editor->setHtml(aStringContainingHTMLtext);
28editor->show();
30
31
33QTextDocument *document = editor->document();
35Q_UNUSED(document);
36
38QTextCursor cursor = editor->textCursor();
40
41
43editor->setTextCursor(cursor);
45
46
49QString paragraphText;
52
53textCursor.beginEditBlock();
54
55for (int i = 0; i < 1000; ++i) {
56 textCursor.insertBlock();
57 textCursor.insertText(paragraphText.at(i));
58}
59
60textCursor.endEditBlock();
62
63} // wrapper2
64} // doc_src_richtext
void show()
Shows the item (items are visible by default).
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant \inmodule QtGui
Definition qtextcursor.h:30
\reentrant \inmodule QtGui
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
Definition qtextedit.h:27
void setTextCursor(const QTextCursor &cursor)
Sets the visible cursor.
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
void setHtml(const QString &text)
QTextDocument * document
the underlying document of the text editor.
Definition qtextedit.h:51
QCursor cursor
#define Q_UNUSED(x)
QGraphicsWidget * textEdit
edit textCursor().insertText(text)
[0]