summaryrefslogtreecommitdiffstats
path: root/src/gui/doc/snippets/scribe-overview/main.cpp
blob: c58c93ec6c346952751a995c7ad749911d3e3461 (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
33
34
35
36
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QTextEdit>

void mergeFormat(QTextEdit *edit)
{
//! [0]
QTextDocument *document = edit->document();
QTextCursor cursor(document);

cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);

QTextCharFormat format;
format.setFontWeight(QFont::Bold);

cursor.mergeCharFormat(format);
//! [0]
}

int main(int argc, char *argv[])
{
QWidget *parent = nullptr;
QString aStringContainingHTMLtext("<h1>Scribe Overview</h1>");

QApplication app(argc, argv);

//! [1]
QTextEdit *editor = new QTextEdit(parent);
editor->setHtml(aStringContainingHTMLtext);
editor->show();
//! [1]

return app.exec();
}