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
src_gui_text_qtextcursor.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 <QImage>
4#include <QTextCursor>
5#include <QTextDocument>
6
9
10void wrapper0() {
11QTextCursor cursor;
12
13
14//! [0]
15cursor.clearSelection();
16cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
17cursor.insertText("Hello World");
18//! [0]
19
20
21//! [1]
22QImage img;
23textDocument->addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
24cursor.insertImage("myimage");
25//! [1]
26
27} // wrapper0
28
29
30void wrapper1() {
31//! [2]
32QTextCursor cursor(textDocument);
33cursor.beginEditBlock();
34cursor.insertText("Hello");
35cursor.insertText("World");
36cursor.endEditBlock();
37
38textDocument->undo();
39//! [2]
40} // wrapper1
41
42
43void wrapper2() {
44//! [3]
45QTextCursor cursor(textDocument);
46cursor.beginEditBlock();
47cursor.insertText("Hello");
48cursor.insertText("World");
49cursor.endEditBlock();
50
51// ...
52
53cursor.joinPreviousEditBlock();
54cursor.insertText("Hey");
55cursor.endEditBlock();
56
57textDocument->undo();
58//! [3]
59} // wrapper2
60
61} // src_gui_text_qtextcursor