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
#include <QTextTable>
6
7
int
main
(
int
argc,
char
* argv[])
8
{
9
int
rows = 6;
10
int
columns = 2;
11
12
QApplication
app
(argc, argv);
13
QTextEdit
*
textEdit
=
new
QTextEdit
;
14
QTextCursor
cursor
(
textEdit
->textCursor());
15
cursor
.movePosition(
QTextCursor::Start
);
16
17
QTextTableFormat
tableFormat;
18
tableFormat.
setAlignment
(
Qt::AlignHCenter
);
19
tableFormat.
setCellPadding
(2);
20
tableFormat.
setCellSpacing
(2);
21
QTextTable
*
table
=
cursor
.insertTable(rows, columns);
22
table
->setFormat(tableFormat);
23
24
QTextCharFormat
boldFormat;
25
boldFormat.
setFontWeight
(
QFont::Bold
);
26
27
QTextBlockFormat
centerFormat;
28
centerFormat.
setAlignment
(
Qt::AlignHCenter
);
29
cursor
.mergeBlockFormat(centerFormat);
30
31
cursor
=
table
->cellAt(0, 0).firstCursorPosition();
32
cursor
.insertText((
"Details"
), boldFormat);
33
34
cursor
=
table
->cellAt(1, 0).firstCursorPosition();
35
cursor
.insertText(
"Alan"
);
36
37
cursor
=
table
->cellAt(1, 1).firstCursorPosition();
38
cursor
.insertText(
"5, Pickety Street"
);
39
41
table
->mergeCells(0, 0, 1, 2);
43
table
->splitCell(0, 0, 1, 1);
45
46
textEdit
->
show
();
47
return
app
.
exec
();
48
}
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
QFont::Bold
@ Bold
Definition
qfont.h:67
QGraphicsItem::show
void show()
Shows the item (items are visible by default).
Definition
qgraphicsitem.h:174
QTextBlockFormat
\reentrant
Definition
qtextformat.h:606
QTextBlockFormat::setAlignment
void setAlignment(Qt::Alignment alignment)
Sets the paragraph's alignment.
Definition
qtextformat.h:699
QTextCharFormat
\reentrant
Definition
qtextformat.h:382
QTextCharFormat::setFontWeight
void setFontWeight(int weight)
Sets the text format's font weight to weight.
Definition
qtextformat.h:447
QTextCursor
\reentrant \inmodule QtGui
Definition
qtextcursor.h:30
QTextCursor::Start
@ Start
Definition
qtextcursor.h:64
QTextEdit
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
Definition
qtextedit.h:27
QTextTableFormat
\reentrant
Definition
qtextformat.h:952
QTextTableFormat::setAlignment
void setAlignment(Qt::Alignment alignment)
Sets the table's alignment.
Definition
qtextformat.h:1011
QTextTableFormat::setCellSpacing
void setCellSpacing(qreal spacing)
Sets the cell spacing for the table.
Definition
qtextformat.h:973
QTextTableFormat::setCellPadding
void setCellPadding(qreal padding)
Sets the cell padding for the table.
Definition
qtextformat.h:1008
QTextTable
\reentrant
Definition
qtexttable.h:63
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
cursor
QCursor cursor
Definition
doc_src_properties.cpp:25
Qt::AlignHCenter
@ AlignHCenter
Definition
qnamespace.h:147
table
GLenum GLenum GLsizei void * table
Definition
qopenglext.h:2745
textEdit
QGraphicsWidget * textEdit
Definition
src_gui_graphicsview_qgraphicsgridlayout.cpp:6
app
QApplication app(argc, argv)
[0]
qtbase
src
gui
doc
snippets
textdocument-texttable
main.cpp
Generated by
1.9.7