blob: 0a4b076f638c8d31ff4d42ac471d5a67656c3de1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QTextEdit>
#include <QTextList>
namespace textdocument_lists {
struct MainWindow
{
void insertList();
private:
QTextEdit *editor = nullptr;
};
void MainWindow::insertList()
{
QTextCursor cursor = editor->textCursor();
QTextList *list = cursor.currentList();
//! [0]
QTextListFormat listFormat;
if (list) {
listFormat = list->format();
listFormat.setIndent(listFormat.indent() + 1);
}
listFormat.setStyle(QTextListFormat::ListDisc);
cursor.insertList(listFormat);
//! [0]
}
} //textdocument_lists
|