Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
main.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 <QApplication>
4
#include <QTextEdit>
5
6
QString
tr
(
const
char
*
text
)
7
{
8
return
QApplication::translate
(
text
,
text
);
9
}
10
11
int
main
(
int
argc,
char
*argv[])
12
{
13
QApplication
app
(argc, argv);
14
QTextEdit
*editor =
new
QTextEdit
;
15
17
QTextDocument
*document =
new
QTextDocument
(editor);
18
QTextCursor
cursor
(document);
20
22
QTextImageFormat
imageFormat;
23
imageFormat.
setName
(
":/images/advert.png"
);
24
cursor
.insertImage(imageFormat);
26
27
cursor
.insertBlock();
28
cursor
.insertText(
"Code less. Create more."
);
29
30
editor->
setDocument
(document);
31
editor->setWindowTitle(
tr
(
"Text Document Images"
));
32
editor->resize(320, 480);
33
editor->show();
34
return
app
.
exec
();
35
}
QApplication
The QApplication class manages the GUI application's control flow and main settings.
Definition
qapplication.h:32
QApplication::exec
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
Definition
qapplication.cpp:2564
QCoreApplication::translate
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
Definition
qcoreapplication.cpp:2314
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
QTextCursor
\reentrant \inmodule QtGui
Definition
qtextcursor.h:30
QTextDocument
\reentrant \inmodule QtGui
Definition
qtextdocument.h:57
QTextEdit
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
Definition
qtextedit.h:27
QTextEdit::setDocument
void setDocument(QTextDocument *document)
Definition
qtextedit.cpp:768
QTextImageFormat
\reentrant
Definition
qtextformat.h:785
QTextImageFormat::setName
void setName(const QString &name)
Sets the name of the image.
Definition
qtextformat.h:820
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
text
QString text
Definition
doc_src_properties.cpp:102
cursor
QCursor cursor
Definition
doc_src_properties.cpp:25
tr
#define tr(X)
Definition
qtemporaryfile.cpp:21
app
QApplication app(argc, argv)
[0]
qtbase
src
gui
doc
snippets
textdocument-images
main.cpp
Generated by
1.9.7