summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tutorials
diff options
context:
space:
mode:
authorNico Vertriest <nico.vertriest@qt.io>2018-05-22 12:23:54 +0200
committerNico Vertriest <nico.vertriest@qt.io>2018-06-01 09:54:56 +0000
commit28738d2d8d6db6b0a771c3c6676450e7269e4f37 (patch)
tree00a360b6389f93941e752127b1cfad53fba98c44 /examples/widgets/tutorials
parent7c87ffff9aa62883bf61efe1bf27704d479eace5 (diff)
Doc: Add formatting features to Notepad example
- bold, italic, underline - About button Change-Id: I8ece7d2bfca0b148b681a2fccb4a439ce179848a Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Diffstat (limited to 'examples/widgets/tutorials')
-rw-r--r--examples/widgets/tutorials/notepad/images/bold.pngbin0 -> 724 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/italic.pngbin0 -> 471 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/underline.pngbin0 -> 520 bytes
-rw-r--r--examples/widgets/tutorials/notepad/notepad.cpp24
-rw-r--r--examples/widgets/tutorials/notepad/notepad.h10
-rw-r--r--examples/widgets/tutorials/notepad/notepad.qrc17
-rw-r--r--examples/widgets/tutorials/notepad/notepad.ui153
7 files changed, 182 insertions, 22 deletions
diff --git a/examples/widgets/tutorials/notepad/images/bold.png b/examples/widgets/tutorials/notepad/images/bold.png
new file mode 100644
index 0000000000..fe737cdb76
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/bold.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/italic.png b/examples/widgets/tutorials/notepad/images/italic.png
new file mode 100644
index 0000000000..337aac23a9
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/italic.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/underline.png b/examples/widgets/tutorials/notepad/images/underline.png
new file mode 100644
index 0000000000..437c45b3b1
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/underline.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp
index 44d8597cb7..99a1a52c2b 100644
--- a/examples/widgets/tutorials/notepad/notepad.cpp
+++ b/examples/widgets/tutorials/notepad/notepad.cpp
@@ -191,3 +191,27 @@ void Notepad::on_actionFont_triggered()
if (fontSelected)
ui->textEdit->setFont(font);
}
+
+void Notepad::on_actionUnderline_triggered()
+{
+ ui->textEdit->setFontUnderline(ui->actionUnderline->isChecked());
+}
+
+void Notepad::on_actionItalic_triggered()
+{
+ ui->textEdit->setFontItalic(ui->actionItalic->isChecked());
+}
+
+void Notepad::on_actionBold_triggered()
+{
+ ui->actionBold->isChecked() ? ui->textEdit->setFontWeight(QFont::Bold) :
+ ui->textEdit->setFontWeight(QFont::Normal);
+}
+
+void Notepad::on_actionAbout_triggered()
+{
+ QMessageBox::about(this, tr("About MDI"),
+ tr("The <b>Notepad</b> example demonstrates how to code a basic "
+ "text editor using QtWidgets"));
+
+}
diff --git a/examples/widgets/tutorials/notepad/notepad.h b/examples/widgets/tutorials/notepad/notepad.h
index f688df45ac..288ab4e373 100644
--- a/examples/widgets/tutorials/notepad/notepad.h
+++ b/examples/widgets/tutorials/notepad/notepad.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -103,6 +103,14 @@ private slots:
void on_actionFont_triggered();
+ void on_actionBold_triggered();
+
+ void on_actionUnderline_triggered();
+
+ void on_actionItalic_triggered();
+
+ void on_actionAbout_triggered();
+
//! [6]
private:
Ui::Notepad *ui;
diff --git a/examples/widgets/tutorials/notepad/notepad.qrc b/examples/widgets/tutorials/notepad/notepad.qrc
index ec11679f13..8c0486bc39 100644
--- a/examples/widgets/tutorials/notepad/notepad.qrc
+++ b/examples/widgets/tutorials/notepad/notepad.qrc
@@ -1,12 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>images/copy.png</file>
- <file>images/create.png</file>
- <file>images/cut.png</file>
- <file>images/edit_redo.png</file>
- <file>images/edit_undo.png</file>
- <file>images/exit.png</file>
- <file>images/font.png</file>
<file>images/info.png</file>
<file>images/new.png</file>
<file>images/open.png</file>
@@ -15,5 +8,15 @@
<file>images/print.png</file>
<file>images/save.png</file>
<file>images/save_as.png</file>
+ <file>images/exit.png</file>
+ <file>images/font.png</file>
+ <file>images/copy.png</file>
+ <file>images/create.png</file>
+ <file>images/cut.png</file>
+ <file>images/edit_redo.png</file>
+ <file>images/edit_undo.png</file>
+ <file>images/bold.png</file>
+ <file>images/italic.png</file>
+ <file>images/underline.png</file>
</qresource>
</RCC>
diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui
index d197a95fe7..4b2a6a0675 100644
--- a/examples/widgets/tutorials/notepad/notepad.ui
+++ b/examples/widgets/tutorials/notepad/notepad.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>524</width>
- <height>300</height>
+ <width>800</width>
+ <height>400</height>
</rect>
</property>
<property name="windowTitle">
@@ -25,7 +25,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>524</width>
+ <width>800</width>
<height>25</height>
</rect>
</property>
@@ -74,7 +74,13 @@
<addaction name="actionPaste"/>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
+ <addaction name="separator"/>
<addaction name="actionFont"/>
+ <addaction name="actionBold"/>
+ <addaction name="actionItalic"/>
+ <addaction name="actionUnderline"/>
+ <addaction name="separator"/>
+ <addaction name="actionAbout"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
@@ -87,105 +93,224 @@
<property name="text">
<string>New</string>
</property>
+ <property name="toolTip">
+ <string>New text document</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
</action>
<action name="actionOpen">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
</property>
<property name="text">
<string>Open</string>
</property>
+ <property name="toolTip">
+ <string>Open file</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
</action>
<action name="actionSave">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
</property>
<property name="text">
<string>Save</string>
</property>
+ <property name="toolTip">
+ <string>Save file</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
</action>
<action name="actionSave_as">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset>
</property>
<property name="text">
<string>Save as</string>
</property>
+ <property name="toolTip">
+ <string>Save file as</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+S</string>
+ </property>
</action>
<action name="actionPrint">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
</property>
<property name="text">
<string>Print</string>
</property>
+ <property name="toolTip">
+ <string>Print file</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+P</string>
+ </property>
</action>
<action name="actionExit">
<property name="icon">
- <iconset>
+ <iconset theme="exit.png" resource="notepad.qrc">
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
</property>
<property name="text">
<string>Exit</string>
</property>
+ <property name="toolTip">
+ <string>Exit notepad</string>
+ </property>
+ <property name="shortcut">
+ </property>
</action>
<action name="actionCopy">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
</property>
<property name="text">
<string>Copy</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+C</string>
+ </property>
</action>
<action name="actionCut">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
</property>
<property name="text">
<string>Cut</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+X</string>
+ </property>
</action>
<action name="actionPaste">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
</property>
<property name="text">
<string>Paste</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+V</string>
+ </property>
</action>
<action name="actionUndo">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset>
</property>
<property name="text">
<string>Undo</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+Z</string>
+ </property>
</action>
<action name="actionRedo">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset>
</property>
<property name="text">
<string>Redo</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+Y</string>
+ </property>
</action>
<action name="actionFont">
<property name="icon">
- <iconset>
+ <iconset resource="notepad.qrc">
<normaloff>:/images/font.png</normaloff>:/images/font.png</iconset>
</property>
<property name="text">
<string>Font</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+F</string>
+ </property>
+ </action>
+ <action name="actionItalic">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="notepad.qrc">
+ <normaloff>:/images/italic.png</normaloff>:/images/italic.png</iconset>
+ </property>
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ <property name="toolTip">
+ <string>Italic font</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+I</string>
+ </property>
+ </action>
+ <action name="actionBold">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="notepad.qrc">
+ <normaloff>:/images/bold.png</normaloff>:/images/bold.png</iconset>
+ </property>
+ <property name="text">
+ <string>actionBold</string>
+ </property>
+ <property name="toolTip">
+ <string>Bold</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+B</string>
+ </property>
+ </action>
+ <action name="actionUnderline">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="notepad.qrc">
+ <normaloff>:/images/underline.png</normaloff>:/images/underline.png</iconset>
+ </property>
+ <property name="text">
+ <string>Underline</string>
+ </property>
+ <property name="toolTip">
+ <string>Underline</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+U</string>
+ </property>
+ </action>
+ <action name="actionAbout">
+ <property name="icon">
+ <iconset resource="notepad.qrc">
+ <normaloff>:/images/info.png</normaloff>:/images/info.png</iconset>
+ </property>
+ <property name="text">
+ <string>About</string>
+ </property>
+ <property name="toolTip">
+ <string>About Notepad</string>
+ </property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>