QtBase  v6.3.1
widget.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include "widget.h"
30 #include "ui_widget.h"
31 
33  QWidget(parent),
34  ui(new Ui::Widget)
35 {
36  ui->setupUi(this);
37 
38  // Changing font size and indent values to verify fix for QTBUG-5111.
39  connect(ui->spinBoxFontPointSize, SIGNAL(valueChanged(int)), this, SLOT(setFontPointSize(int)));
40  connect(ui->spinBoxIndentWidth, SIGNAL(valueChanged(int)), this, SLOT(setIndentWidth(int)));
41 
42  textCursor = new QTextCursor(ui->textEdit->document());
43 
44  // Initialize text list with different formats and layouts
45  QTextListFormat listFormat;
46  // disc
48  textCursor->insertList(listFormat);
49  textCursor->insertText("disc one");
50  textCursor->insertText("\ndisc two");
51  // 1., 2.
53  textCursor->insertList(listFormat);
54  textCursor->insertText("decimal one");
55  textCursor->insertText("\ndecimal two");
56  // a., b.
58  textCursor->insertList(listFormat);
59  textCursor->insertText("lower alpha one");
60  textCursor->insertText("\nlower alpha two");
61  // A., B.
63  textCursor->insertList(listFormat);
64  textCursor->insertText("upper alpha one");
65  textCursor->insertText("\nupper alpha two");
66  // Indent 1
68  listFormat.setIndent(1);
69  textCursor->insertList(listFormat);
70  textCursor->insertText("indent 1 one");
71  textCursor->insertText("\nindent 2 two");
72  // Indent 2
73  listFormat.setIndent(2);
74  textCursor->insertList(listFormat);
75  textCursor->insertText("indent 2 one");
76  textCursor->insertText("\nindent 2 two");
77  // Indent 3
78  listFormat.setIndent(3);
79  textCursor->insertList(listFormat);
80  textCursor->insertText("indent 3 one");
81  textCursor->insertText("\nindent 3 two");
82  // right to left: disc
83  listFormat.setIndent(1);
85  textCursor->insertList(listFormat);
86  textCursor->insertText(QChar( 0x05d0)); // use Hebrew aleph to create a right-to-left layout
87  textCursor->insertText("\n" + QString(QChar( 0x05d0)));
88  // right to left: 1., 2.
90  textCursor->insertList(listFormat);
91  textCursor->insertText(QChar( 0x05d0)); // use Hebrew aleph to create a right-to-left layout
92  textCursor->insertText("\n" + QString(QChar( 0x05d0)));
93 
94  QFont font;
95  setFontPointSize(font.pointSize());
96  ui->textEdit->setFont(font);
97 
98  setIndentWidth(static_cast<int>(ui->textEdit->document()->indentWidth()));
99 }
100 
102 {
103  ui->textEdit->selectAll();
104  ui->textEdit->setFontPointSize(value);
105 }
106 
108 {
109  ui->textEdit->document()->setIndentWidth(value);
110 }
111 
113 {
114  delete ui;
115  delete textCursor;
116 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:84
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
int pointSize() const
Definition: qfont.cpp:899
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:67
The QTextListFormat class provides formatting information for lists in a QTextDocument....
Definition: qtextformat.h:757
void setStyle(Style style)
Definition: qtextformat.h:798
void setIndent(int indent)
Definition: qtextformat.h:801
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
setupUi(QWidget *widget)
Definition: widget.h:60
void setIndentWidth(int value)
Definition: widget.cpp:107
~Widget()
Definition: widget.cpp:78
void setFontPointSize(int value)
Definition: widget.cpp:101
#define QString()
Definition: parse-defines.h:51
EGLOutputLayerEXT EGLint EGLAttrib value
#define SLOT(a)
Definition: qobjectdefs.h:87
#define SIGNAL(a)
Definition: qobjectdefs.h:88
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
edit textCursor().insertText(text)
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent