summaryrefslogtreecommitdiffstats
path: root/examples/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets')
-rw-r--r--examples/widgets/animation/easing/images/qt-logo.pngbin1495 -> 1165 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.cpp124
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.pro12
-rw-r--r--examples/widgets/dialogs/configdialog/configdialog.qrc7
-rw-r--r--examples/widgets/dialogs/configdialog/images/config.pngbin6758 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/images/query.pngbin2116 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/images/update.pngbin7890 -> 0 bytes
-rw-r--r--examples/widgets/dialogs/configdialog/pages.cpp161
-rw-r--r--examples/widgets/dialogs/configdialog/pages.h74
-rw-r--r--examples/widgets/dialogs/dialogs.pro1
-rw-r--r--examples/widgets/dialogs/findfiles/window.cpp57
-rw-r--r--examples/widgets/dialogs/findfiles/window.h2
-rw-r--r--examples/widgets/doc/images/graphicssimpleanchorlayout-example.pngbin16743 -> 11301 bytes
-rw-r--r--examples/widgets/doc/images/notepad.pngbin0 -> 12418 bytes
-rw-r--r--examples/widgets/doc/images/notepad1.pngbin0 -> 12418 bytes
-rw-r--r--examples/widgets/doc/images/notepad2.pngbin0 -> 22700 bytes
-rw-r--r--examples/widgets/doc/images/notepad3.pngbin0 -> 40584 bytes
-rw-r--r--examples/widgets/doc/images/notepad4.pngbin0 -> 9494 bytes
-rw-r--r--examples/widgets/doc/images/notepad_menu.pngbin0 -> 8657 bytes
-rw-r--r--examples/widgets/doc/src/configdialog.qdoc37
-rw-r--r--examples/widgets/doc/src/draggabletext.qdoc1
-rw-r--r--examples/widgets/doc/src/easing.qdoc3
-rw-r--r--examples/widgets/doc/src/findfiles.qdoc41
-rw-r--r--examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc46
-rw-r--r--examples/widgets/tutorials/gettingstartedqt.qdoc559
-rw-r--r--examples/widgets/tutorials/notepad/images/copy.pngbin0 -> 1633 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/create.pngbin0 -> 459 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/cut.pngbin0 -> 9554 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/edit_redo.pngbin0 -> 7463 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/edit_undo.pngbin0 -> 8424 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/exit.pngbin0 -> 379 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/font.pngbin0 -> 6983 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/info.pngbin0 -> 557 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/new.pngbin0 -> 7422 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/open.pngbin0 -> 5437 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/paste.pngbin0 -> 3597 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/pencil.pngbin0 -> 3780 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/print.pngbin0 -> 331 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/save.pngbin0 -> 2699 bytes
-rw-r--r--examples/widgets/tutorials/notepad/images/save_as.pngbin0 -> 8209 bytes
-rw-r--r--examples/widgets/tutorials/notepad/main.cpp (renamed from examples/widgets/dialogs/configdialog/main.cpp)16
-rw-r--r--examples/widgets/tutorials/notepad/notepad.cpp182
-rw-r--r--examples/widgets/tutorials/notepad/notepad.h (renamed from examples/widgets/dialogs/configdialog/configdialog.h)69
-rw-r--r--examples/widgets/tutorials/notepad/notepad.pro20
-rw-r--r--examples/widgets/tutorials/notepad/notepad.qrc19
-rw-r--r--examples/widgets/tutorials/notepad/notepad.ui196
-rw-r--r--examples/widgets/tutorials/tutorials.pro2
47 files changed, 1132 insertions, 497 deletions
diff --git a/examples/widgets/animation/easing/images/qt-logo.png b/examples/widgets/animation/easing/images/qt-logo.png
index 6b72d5fb72..d10bd0bdf9 100644
--- a/examples/widgets/animation/easing/images/qt-logo.png
+++ b/examples/widgets/animation/easing/images/qt-logo.png
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/configdialog.cpp b/examples/widgets/dialogs/configdialog/configdialog.cpp
deleted file mode 100644
index 5a0fb1c3bc..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "configdialog.h"
-#include "pages.h"
-
-ConfigDialog::ConfigDialog()
-{
- contentsWidget = new QListWidget;
- contentsWidget->setViewMode(QListView::IconMode);
- contentsWidget->setIconSize(QSize(96, 84));
- contentsWidget->setMovement(QListView::Static);
- contentsWidget->setMaximumWidth(128);
- contentsWidget->setSpacing(12);
-
- pagesWidget = new QStackedWidget;
- pagesWidget->addWidget(new ConfigurationPage);
- pagesWidget->addWidget(new UpdatePage);
- pagesWidget->addWidget(new QueryPage);
-
- QPushButton *closeButton = new QPushButton(tr("Close"));
-
- createIcons();
- contentsWidget->setCurrentRow(0);
-
- connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close);
-
- QHBoxLayout *horizontalLayout = new QHBoxLayout;
- horizontalLayout->addWidget(contentsWidget);
- horizontalLayout->addWidget(pagesWidget, 1);
-
- QHBoxLayout *buttonsLayout = new QHBoxLayout;
- buttonsLayout->addStretch(1);
- buttonsLayout->addWidget(closeButton);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addLayout(horizontalLayout);
- mainLayout->addStretch(1);
- mainLayout->addSpacing(12);
- mainLayout->addLayout(buttonsLayout);
- setLayout(mainLayout);
-
- setWindowTitle(tr("Config Dialog"));
-}
-
-void ConfigDialog::createIcons()
-{
- QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
- configButton->setIcon(QIcon(":/images/config.png"));
- configButton->setText(tr("Configuration"));
- configButton->setTextAlignment(Qt::AlignHCenter);
- configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- QListWidgetItem *updateButton = new QListWidgetItem(contentsWidget);
- updateButton->setIcon(QIcon(":/images/update.png"));
- updateButton->setText(tr("Update"));
- updateButton->setTextAlignment(Qt::AlignHCenter);
- updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- QListWidgetItem *queryButton = new QListWidgetItem(contentsWidget);
- queryButton->setIcon(QIcon(":/images/query.png"));
- queryButton->setText(tr("Query"));
- queryButton->setTextAlignment(Qt::AlignHCenter);
- queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage);
-}
-
-void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
-{
- if (!current)
- current = previous;
-
- pagesWidget->setCurrentIndex(contentsWidget->row(current));
-}
diff --git a/examples/widgets/dialogs/configdialog/configdialog.pro b/examples/widgets/dialogs/configdialog/configdialog.pro
deleted file mode 100644
index 8ba55becad..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-QT += widgets
-
-HEADERS = configdialog.h \
- pages.h
-SOURCES = configdialog.cpp \
- main.cpp \
- pages.cpp
-RESOURCES += configdialog.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/configdialog
-INSTALLS += target
diff --git a/examples/widgets/dialogs/configdialog/configdialog.qrc b/examples/widgets/dialogs/configdialog/configdialog.qrc
deleted file mode 100644
index 31d0d49666..0000000000
--- a/examples/widgets/dialogs/configdialog/configdialog.qrc
+++ /dev/null
@@ -1,7 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>images/config.png</file>
- <file>images/query.png</file>
- <file>images/update.png</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/dialogs/configdialog/images/config.png b/examples/widgets/dialogs/configdialog/images/config.png
deleted file mode 100644
index 5c14d5f470..0000000000
--- a/examples/widgets/dialogs/configdialog/images/config.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/images/query.png b/examples/widgets/dialogs/configdialog/images/query.png
deleted file mode 100644
index ea9e291eeb..0000000000
--- a/examples/widgets/dialogs/configdialog/images/query.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/images/update.png b/examples/widgets/dialogs/configdialog/images/update.png
deleted file mode 100644
index 3cb8ba6c77..0000000000
--- a/examples/widgets/dialogs/configdialog/images/update.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/pages.cpp b/examples/widgets/dialogs/configdialog/pages.cpp
deleted file mode 100644
index 0c7762f029..0000000000
--- a/examples/widgets/dialogs/configdialog/pages.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "pages.h"
-
-ConfigurationPage::ConfigurationPage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *configGroup = new QGroupBox(tr("Server configuration"));
-
- QLabel *serverLabel = new QLabel(tr("Server:"));
- QComboBox *serverCombo = new QComboBox;
- serverCombo->addItem(tr("Qt (Australia)"));
- serverCombo->addItem(tr("Qt (Germany)"));
- serverCombo->addItem(tr("Qt (Norway)"));
- serverCombo->addItem(tr("Qt (People's Republic of China)"));
- serverCombo->addItem(tr("Qt (USA)"));
-
- QHBoxLayout *serverLayout = new QHBoxLayout;
- serverLayout->addWidget(serverLabel);
- serverLayout->addWidget(serverCombo);
-
- QVBoxLayout *configLayout = new QVBoxLayout;
- configLayout->addLayout(serverLayout);
- configGroup->setLayout(configLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(configGroup);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
-
-UpdatePage::UpdatePage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *updateGroup = new QGroupBox(tr("Package selection"));
- QCheckBox *systemCheckBox = new QCheckBox(tr("Update system"));
- QCheckBox *appsCheckBox = new QCheckBox(tr("Update applications"));
- QCheckBox *docsCheckBox = new QCheckBox(tr("Update documentation"));
-
- QGroupBox *packageGroup = new QGroupBox(tr("Existing packages"));
-
- QListWidget *packageList = new QListWidget;
- QListWidgetItem *qtItem = new QListWidgetItem(packageList);
- qtItem->setText(tr("Qt"));
- QListWidgetItem *qsaItem = new QListWidgetItem(packageList);
- qsaItem->setText(tr("QSA"));
- QListWidgetItem *teamBuilderItem = new QListWidgetItem(packageList);
- teamBuilderItem->setText(tr("Teambuilder"));
-
- QPushButton *startUpdateButton = new QPushButton(tr("Start update"));
-
- QVBoxLayout *updateLayout = new QVBoxLayout;
- updateLayout->addWidget(systemCheckBox);
- updateLayout->addWidget(appsCheckBox);
- updateLayout->addWidget(docsCheckBox);
- updateGroup->setLayout(updateLayout);
-
- QVBoxLayout *packageLayout = new QVBoxLayout;
- packageLayout->addWidget(packageList);
- packageGroup->setLayout(packageLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(updateGroup);
- mainLayout->addWidget(packageGroup);
- mainLayout->addSpacing(12);
- mainLayout->addWidget(startUpdateButton);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
-
-QueryPage::QueryPage(QWidget *parent)
- : QWidget(parent)
-{
- QGroupBox *packagesGroup = new QGroupBox(tr("Look for packages"));
-
- QLabel *nameLabel = new QLabel(tr("Name:"));
- QLineEdit *nameEdit = new QLineEdit;
-
- QLabel *dateLabel = new QLabel(tr("Released after:"));
- QDateTimeEdit *dateEdit = new QDateTimeEdit(QDate::currentDate());
-
- QCheckBox *releasesCheckBox = new QCheckBox(tr("Releases"));
- QCheckBox *upgradesCheckBox = new QCheckBox(tr("Upgrades"));
-
- QSpinBox *hitsSpinBox = new QSpinBox;
- hitsSpinBox->setPrefix(tr("Return up to "));
- hitsSpinBox->setSuffix(tr(" results"));
- hitsSpinBox->setSpecialValueText(tr("Return only the first result"));
- hitsSpinBox->setMinimum(1);
- hitsSpinBox->setMaximum(100);
- hitsSpinBox->setSingleStep(10);
-
- QPushButton *startQueryButton = new QPushButton(tr("Start query"));
-
- QGridLayout *packagesLayout = new QGridLayout;
- packagesLayout->addWidget(nameLabel, 0, 0);
- packagesLayout->addWidget(nameEdit, 0, 1);
- packagesLayout->addWidget(dateLabel, 1, 0);
- packagesLayout->addWidget(dateEdit, 1, 1);
- packagesLayout->addWidget(releasesCheckBox, 2, 0);
- packagesLayout->addWidget(upgradesCheckBox, 3, 0);
- packagesLayout->addWidget(hitsSpinBox, 4, 0, 1, 2);
- packagesGroup->setLayout(packagesLayout);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(packagesGroup);
- mainLayout->addSpacing(12);
- mainLayout->addWidget(startQueryButton);
- mainLayout->addStretch(1);
- setLayout(mainLayout);
-}
diff --git a/examples/widgets/dialogs/configdialog/pages.h b/examples/widgets/dialogs/configdialog/pages.h
deleted file mode 100644
index beb7f86ae0..0000000000
--- a/examples/widgets/dialogs/configdialog/pages.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PAGES_H
-#define PAGES_H
-
-#include <QWidget>
-
-class ConfigurationPage : public QWidget
-{
-public:
- ConfigurationPage(QWidget *parent = 0);
-};
-
-class QueryPage : public QWidget
-{
-public:
- QueryPage(QWidget *parent = 0);
-};
-
-class UpdatePage : public QWidget
-{
-public:
- UpdatePage(QWidget *parent = 0);
-};
-
-#endif
diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro
index a29903938e..753308fc55 100644
--- a/examples/widgets/dialogs/dialogs.pro
+++ b/examples/widgets/dialogs/dialogs.pro
@@ -2,7 +2,6 @@ QT_FOR_CONFIG += widgets
TEMPLATE = subdirs
SUBDIRS = classwizard \
- configdialog \
extension \
findfiles \
licensewizard \
diff --git a/examples/widgets/dialogs/findfiles/window.cpp b/examples/widgets/dialogs/findfiles/window.cpp
index f2ce853d99..1b16cdcd35 100644
--- a/examples/widgets/dialogs/findfiles/window.cpp
+++ b/examples/widgets/dialogs/findfiles/window.cpp
@@ -74,6 +74,7 @@ static inline void openFile(const QString &fileName)
Window::Window(QWidget *parent)
: QWidget(parent)
{
+ setWindowTitle(tr("Find Files"));
QPushButton *browseButton = new QPushButton(tr("&Browse..."), this);
connect(browseButton, &QAbstractButton::clicked, this, &Window::browse);
findButton = new QPushButton(tr("&Find"), this);
@@ -92,9 +93,7 @@ Window::Window(QWidget *parent)
filesFoundLabel = new QLabel;
createFilesTable();
-//! [0]
-//! [1]
QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->addWidget(new QLabel(tr("Named:")), 0, 0);
mainLayout->addWidget(fileComboBox, 0, 1, 1, 2);
@@ -106,12 +105,13 @@ Window::Window(QWidget *parent)
mainLayout->addWidget(filesTable, 3, 0, 1, 3);
mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2);
mainLayout->addWidget(findButton, 4, 2);
+//! [0]
- setWindowTitle(tr("Find Files"));
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
- resize(screenGeometry.width() / 2, screenGeometry.height() / 3);
-}
//! [1]
+ connect(new QShortcut(QKeySequence::Quit, this), &QShortcut::activated,
+ qApp, &QApplication::quit);
+//! [1]
+}
//! [2]
void Window::browse()
@@ -133,21 +133,7 @@ static void updateComboBox(QComboBox *comboBox)
comboBox->addItem(comboBox->currentText());
}
-//! [13]
-
-static void findRecursion(const QString &path, const QString &pattern, QStringList *result)
-{
- QDir currentDir(path);
- const QString prefix = path + QLatin1Char('/');
- foreach (const QString &match, currentDir.entryList(QStringList(pattern), QDir::Files | QDir::NoSymLinks))
- result->append(prefix + match);
- foreach (const QString &dir, currentDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot))
- findRecursion(prefix + dir, pattern, result);
-}
-
-//! [13]
//! [3]
-
void Window::find()
{
filesTable->setRowCount(0);
@@ -155,6 +141,7 @@ void Window::find()
QString fileName = fileComboBox->currentText();
QString text = textComboBox->currentText();
QString path = QDir::cleanPath(directoryComboBox->currentText());
+ currentDir = QDir(path);
//! [3]
updateComboBox(fileComboBox);
@@ -162,12 +149,16 @@ void Window::find()
updateComboBox(directoryComboBox);
//! [4]
-
- currentDir = QDir(path);
+ QStringList filter;
+ if (!fileName.isEmpty())
+ filter << fileName;
+ QDirIterator it(path, filter, QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
QStringList files;
- findRecursion(path, fileName.isEmpty() ? QStringLiteral("*") : fileName, &files);
+ while (it.hasNext())
+ files << it.next();
if (!text.isEmpty())
files = findFiles(files, text);
+ files.sort();
showFiles(files);
}
//! [4]
@@ -225,20 +216,18 @@ QStringList Window::findFiles(const QStringList &files, const QString &text)
//! [7]
//! [8]
-void Window::showFiles(const QStringList &files)
+void Window::showFiles(const QStringList &paths)
{
- for (int i = 0; i < files.size(); ++i) {
- const QString &fileName = files.at(i);
- const QString toolTip = QDir::toNativeSeparators(fileName);
- const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(fileName));
- const qint64 size = QFileInfo(fileName).size();
+ for (const QString &filePath : paths) {
+ const QString toolTip = QDir::toNativeSeparators(filePath);
+ const QString relativePath = QDir::toNativeSeparators(currentDir.relativeFilePath(filePath));
+ const qint64 size = QFileInfo(filePath).size();
QTableWidgetItem *fileNameItem = new QTableWidgetItem(relativePath);
- fileNameItem->setData(absoluteFileNameRole, QVariant(fileName));
+ fileNameItem->setData(absoluteFileNameRole, QVariant(filePath));
fileNameItem->setToolTip(toolTip);
fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
- QTableWidgetItem *sizeItem = new QTableWidgetItem(tr("%1 KB")
- .arg(int((size + 1023) / 1024)));
- sizeItem->setData(absoluteFileNameRole, QVariant(fileName));
+ QTableWidgetItem *sizeItem = new QTableWidgetItem(QLocale().formattedDataSize(size));
+ sizeItem->setData(absoluteFileNameRole, QVariant(filePath));
sizeItem->setToolTip(toolTip);
sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);
@@ -248,7 +237,7 @@ void Window::showFiles(const QStringList &files)
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);
}
- filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", 0, files.size()));
+ filesFoundLabel->setText(tr("%n file(s) found (Double click on a file to open it)", 0, paths.size()));
filesFoundLabel->setWordWrap(true);
}
//! [8]
diff --git a/examples/widgets/dialogs/findfiles/window.h b/examples/widgets/dialogs/findfiles/window.h
index fe217381e2..949df704bb 100644
--- a/examples/widgets/dialogs/findfiles/window.h
+++ b/examples/widgets/dialogs/findfiles/window.h
@@ -79,7 +79,7 @@ private slots:
private:
QStringList findFiles(const QStringList &files, const QString &text);
- void showFiles(const QStringList &files);
+ void showFiles(const QStringList &paths);
QComboBox *createComboBox(const QString &text = QString());
void createFilesTable();
diff --git a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
index 543670e05c..e4bed44edf 100644
--- a/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
+++ b/examples/widgets/doc/images/graphicssimpleanchorlayout-example.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad.png b/examples/widgets/doc/images/notepad.png
new file mode 100644
index 0000000000..40d13269b9
--- /dev/null
+++ b/examples/widgets/doc/images/notepad.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad1.png b/examples/widgets/doc/images/notepad1.png
new file mode 100644
index 0000000000..40d13269b9
--- /dev/null
+++ b/examples/widgets/doc/images/notepad1.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad2.png b/examples/widgets/doc/images/notepad2.png
new file mode 100644
index 0000000000..9cec1f9a58
--- /dev/null
+++ b/examples/widgets/doc/images/notepad2.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad3.png b/examples/widgets/doc/images/notepad3.png
new file mode 100644
index 0000000000..426861ab06
--- /dev/null
+++ b/examples/widgets/doc/images/notepad3.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad4.png b/examples/widgets/doc/images/notepad4.png
new file mode 100644
index 0000000000..fc08eab204
--- /dev/null
+++ b/examples/widgets/doc/images/notepad4.png
Binary files differ
diff --git a/examples/widgets/doc/images/notepad_menu.png b/examples/widgets/doc/images/notepad_menu.png
new file mode 100644
index 0000000000..2dd771111a
--- /dev/null
+++ b/examples/widgets/doc/images/notepad_menu.png
Binary files differ
diff --git a/examples/widgets/doc/src/configdialog.qdoc b/examples/widgets/doc/src/configdialog.qdoc
deleted file mode 100644
index 9f2cc21adb..0000000000
--- a/examples/widgets/doc/src/configdialog.qdoc
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example dialogs/configdialog
- \title Config Dialog Example
- \ingroup examples-dialogs
-
- \brief The Config Dialog examples shows how a configuration dialog can be created by
- using an icon view with a stacked widget.
-
- \image configdialog-example.png
-*/
diff --git a/examples/widgets/doc/src/draggabletext.qdoc b/examples/widgets/doc/src/draggabletext.qdoc
index c4a694028b..97b2f036bd 100644
--- a/examples/widgets/doc/src/draggabletext.qdoc
+++ b/examples/widgets/doc/src/draggabletext.qdoc
@@ -28,6 +28,7 @@
/*!
\example draganddrop/draggabletext
\title Draggable Text Example
+ \brief Illustrates how to drag and drop text between widgets
\brief The Draggable Text example shows how to drag and drop textual data between widgets
in the same application, and between different applications.
diff --git a/examples/widgets/doc/src/easing.qdoc b/examples/widgets/doc/src/easing.qdoc
index 3a9727d393..807dd72e93 100644
--- a/examples/widgets/doc/src/easing.qdoc
+++ b/examples/widgets/doc/src/easing.qdoc
@@ -34,4 +34,7 @@
\image easing-example.png
+ See \l QEasingCurve for a detailed description on how to use the class's
+ functionalities.
+
*/
diff --git a/examples/widgets/doc/src/findfiles.qdoc b/examples/widgets/doc/src/findfiles.qdoc
index b8363dc698..a2eb326519 100644
--- a/examples/widgets/doc/src/findfiles.qdoc
+++ b/examples/widgets/doc/src/findfiles.qdoc
@@ -74,19 +74,23 @@
\snippet dialogs/findfiles/window.cpp 0
- We create the application's buttons using the private \c
- createButton() function. Then we create the comboboxes associated
- with the search specifications, using the private \c
- createComboBox() function. We also create the application's labels
- before we use the private \c createFilesTable() function to create
- the table displaying the search results.
+ We create the widgets to build up the UI, and we add them to a main layout
+ using QGridLayout. We have, however, put the \c Find and \c Quit buttons
+ and a stretchable space in a separate \l QHBoxLayout first, to make the
+ buttons appear in the \c Window widget's bottom right corner.
+
+ Alternatively, we could have used Qt Designer to construct a UI file,
+ and \l {uic} to generate this code.
\snippet dialogs/findfiles/window.cpp 1
- Then we add all the widgets to a main layout using QGridLayout. We
- have, however, put the \c Find and \c Quit buttons and a
- stretchable space in a separate QHBoxLayout first, to make the
- buttons appear in the \c Window widget's bottom right corner.
+ We did not create a \l QMenuBar with a \uicontrol Quit menu item; but we
+ would still like to have a keyboard shortcut for quitting. Since we
+ construct a \l QShortcut with \l QKeySequence::Quit, and connect it to
+ \l QApplication::quit(), on most platforms it will be possible to press
+ Control-Q to quit (or whichever standard Quit key is configured on that platform).
+ (On \macos, this is redundant, because every application gets a
+ \uicontrol Quit menu item automatically; but it helps to make the application portable.)
\snippet dialogs/findfiles/window.cpp 2
@@ -122,18 +126,16 @@
We use the directory's path to create a QDir; the QDir class
provides access to directory structures and their contents.
- \snippet dialogs/findfiles/window.cpp 13
-
- We recursively create a list of the files (contained in the newl
- created QDir) that match the specified file name.
+ We use QDirIterator to iterate over the files that match the
+ specified file name and build a QStringList of paths.
Then we search through all the files in the list, using the private
- \c findFiles() function, eliminating the ones that don't contain
- the specified text. And finally, we display the results using the
- private \c showFiles() function.
+ \c findFiles() function, eliminating the ones that don't contain the
+ specified text. We sort them (because QDirIterator did not). And finally,
+ we display the results using the private \c showFiles() function.
If the user didn't specify any text, there is no reason to search
- through the files, and we display the results immediately.
+ through the files, so we sort and display the results immediately.
\image findfiles_progress_dialog.png Screenshot of the Progress Dialog
@@ -196,7 +198,8 @@
the \c find() slot. In the \c showFiles() function we run through
the provided list of file names, adding each relative file name to the
first column in the table widget and retrieving the file's size using
- QFileInfo for the second column. For later use, we set
+ QFileInfo for the second column. We use \l QLocale::formattedDataSize()
+ to format the file size in a human-readable form. For later use, we set
the absolute path as a data on the QTableWidget using the
the role absoluteFileNameRole defined to be Qt::UserRole + 1.
diff --git a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
index 866dac442b..fd0427fdc0 100644
--- a/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
+++ b/examples/widgets/doc/src/graphicsview-simpleanchorlayout.qdoc
@@ -35,4 +35,50 @@
QGraphicsAnchorLayout class.
\image graphicssimpleanchorlayout-example.png
+
+ The example starts by creating a QGraphicsScene (\c scene), 3 widgets
+ (\c a, \c b, and \c c), and a QGraphicsAnchorlayout (\c layout).
+
+ \quotefromfile graphicsview/simpleanchorlayout/main.cpp
+ \skipto QGraphicsScene
+ \printuntil QGraphicsAnchorLayout
+
+ First it anchors the top left corner of item \c a to the top left
+ corner of \c layout. This can be done in two steps:
+
+ \skipto layout->addAnchor(a
+ \printto adding
+
+ Or in one step:
+
+ \skipuntil [adding a corner anchor]
+ \printline layout->addCornerAnchors(a, Qt::T
+
+ Then the right anchor of \c a is anchored to the left anchor of
+ \c b, and the top of item \c b is anchored to the bottom of \c a.
+
+ \skipuntil [adding anchors]
+ \printto adding anchors
+
+ Place a third widget \c c under widget \c b:
+
+ \skipuntil third widget
+ \printline AnchorBottom
+
+ Items \c b and \c c are anchored to each other horizontally:
+
+ \skipto Qt::Horizontal
+ \printline Qt::Horizontal
+
+ Item c is anchored to the bottom right point of \c layout
+
+ \skipuntil corner of the layout
+ \printline Qt::BottomRightCorner
+
+ Finally, QGraphicsWidget \c w is displayed in QGraphicsView \c view.
+
+ \skipto QGraphicsWidget
+ \printuntil app.exec()
+
+ \sa {Anchor Layout Example}
*/
diff --git a/examples/widgets/tutorials/gettingstartedqt.qdoc b/examples/widgets/tutorials/gettingstartedqt.qdoc
new file mode 100644
index 0000000000..921dd7a32d
--- /dev/null
+++ b/examples/widgets/tutorials/gettingstartedqt.qdoc
@@ -0,0 +1,559 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example tutorials/notepad
+ \title Getting Started Programming with Qt Widgets
+ \brief A tutorial for Qt Widgets based on a notepad application
+
+ In this topic, we teach basic Qt knowledge by implementing a simple
+ Notepad application using C++ and the \l{Qt Widgets} module. The
+ application is a small text editor which allows you to create a text
+ file, save it, print it,
+ or reopen and edit it again. You can also set the font to be used.
+
+ \image notepad1.png "Notepad application"
+
+ You can find the final Notepad source files in the qtdoc repository
+ in the tutorials/notepad directory. You can either fetch
+ the Qt 5 sources from Qt Project or install them as part of Qt 5.
+ The application is also available in the example list of Qt Creator's
+ Welcome mode.
+
+ \section1 Creating the Notepad Project
+
+ Setting up a new project in Qt Creator is aided by a wizard that
+ guides you step-by-step through the project creation process. The
+ wizard prompts you to enter the settings needed for that particular
+ type of project and creates the project for you.
+
+ \image notepad2.png "Qt Creator New File or Project dialog"
+
+ To create the Notepad project, select \b File > \b{New File or
+ Project} > \b Applications > \b {Qt Widgets Application} > \b Choose,
+ and follow the instructions of the wizard. In the
+ \b{Class Information}
+ dialog, type \b Notepad as the class name and select \b QMainWindow
+ as the base class.
+
+ \image notepad3.png "Class Information Dialog"
+
+ The \b {Qt Widgets Application} wizard creates a project that contains
+ a main source file and a set of files that specify a user interface
+ (Notepad widget):
+
+ \list
+ \li notepad.pro - the project file.
+ \li main.cpp - the main source file for the application.
+ \li notepad.cpp - the source file of the notepad class of the
+ Notepad widget.
+ \li notepad.h - the header file of the notepad class for the
+ Notepad widget.
+ \li notepad.ui - the UI form for the Notepad widget.
+ \endlist
+
+ The .cpp, .h, and .ui files come with the necessary boiler plate code
+ for you to be able to build and run the project. The .pro file is
+ complete.
+ We will take a closer look at the file contents in the following
+ sections.
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Using Qt Creator
+ \li \l{Qt Creator Manual}{Qt Creator}
+ \row
+ \li Creating other kind of applications with Qt Creator
+ \li \l{Qt Creator: Tutorials}{Qt Creator Tutorials}
+ \endtable
+
+
+ \section1 Main Source File
+
+ The wizard generates the following code in the main.cpp file:
+
+ \quotefromfile tutorials/notepad/main.cpp
+ \skipto "notepad.h"
+ \printuntil EditorApp.exec()
+ \printuntil }
+
+ We will go through the code line by line. The following lines include
+ the header files for the Notepad widget and QApplication. All Qt classes
+ have a header file named after them.
+
+ \quotefromfile tutorials/notepad/main.cpp
+ \skipto notepad.h
+ \printuntil QApplication
+
+ The following line defines the main function that is the entry point
+ for all C and C++ based applications:
+
+ \printline main
+
+ The following line creates a QApplication object. This object manages
+ application-wide resources and is necessary to run any Qt program
+ that uses Qt Widgets. It constructs an application object with \c argc
+ command line arguments run in \c argv. (For GUI applications that
+ do not use Qt Widgets, you can use QGuiApplication instead.)
+
+ \skipuntil {
+ \printuntil QApplication
+
+ The following line creates the Notepad object. This is the object for
+ which the wizard created the class and the UI file. The user interface
+ contains visual elements that are called \c widgets in Qt. Examples
+ of widgets are text edits, scroll bars, labels, and radio buttons. A
+ widget can also be a container for other widgets; a dialog or a main
+ application window, for example.
+
+ \printline Notepad
+
+ The following line shows the Notepad widget on the screen in its own
+ window. Widgets can also function as containers. An example of this
+ is QMainWindow which often contains several types of widgets. Widgets
+ are not visible by default; the function \l{QWidget::}{show()} makes
+ the widget visible.
+
+ \printline Editor.show
+
+ The following line makes the QApplication enter its event loop. When
+ a Qt application is running, events are generated and sent to the
+ widgets of the application. Examples of events are mouse presses
+ and key strokes.
+
+ \printline EditorApp.exec
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Widgets and Window Geometry
+ \li \l{Window and Dialog Widgets}
+ \row
+ \li Events and event handling
+ \li \l{The Event System}
+ \endtable
+
+ \section1 Designing a UI
+
+ The wizard generates a user interface definition in XML format: notepad.ui.
+ When you open the notepad.ui file in Qt Creator, it automatically
+ opens in the integrated Qt Designer.
+
+ When you build the application, Qt Creator launches the Qt
+ \l{User Interface Compiler (uic)} that reads the .ui file and creates
+ a corresponding C++ header file, ui_notepad.h.
+
+ \section2 Using Qt Designer
+
+ The wizard creates an application that uses a QMainWindow. It has
+ its own layout to which you can add a menu bar, dock widgets, toolbars,
+ and a status bar. The center area can be occupied by any kind of widget.
+ The wizard places the Notepad widget there.
+
+ To add widgets in Qt Designer:
+
+ \list 1
+ \li In the Qt Creator \b Editor mode, double-click the notepad.ui
+ file in the \b Projects view to launch the file in the integrated
+ Qt Designer.
+ \li Drag and drop widgets Text Edit (QTextEdit) to the form.
+ \li Press \b {Ctrl+A} (or \b {Cmd+A}) to select the widgets and click
+ \b {Lay out Vertically} (or press \b {Ctrl+L}) to apply a vertical
+ layout (QVBoxLayout).
+ \li Press \b {Ctrl+S} (or \b {Cmd+S}) to save your changes.
+ \endlist
+
+ The UI now looks as follows in Qt Designer:
+
+ \image notepad4.png
+
+ You can view the generated XML file in the code editor:
+
+ \quotefromfile tutorials/notepad/notepad.ui
+
+ \printuntil QMenuBar
+ \dots
+
+ The following line contains the XML declaration, which specifies the
+ XML version and character encoding used in the document:
+
+ \code
+ <?xml version="1.0" encoding="UTF-8"?>
+ \endcode
+
+ The rest of the file specifies an \c ui element that defines a
+ Notepad widget:
+
+ \code
+ <ui version="4.0">
+ \endcode
+
+ The UI file is used together with the header and source file of the
+ Notepad class. We will look at the rest of the UI file in the later
+ sections.
+
+ \section2 Notepad Header File
+
+ The wizard generated a header file for the Notepad class that has the
+ necessary #includes, a constructor, a destructor, and the Ui object.
+ The file looks as follows:
+
+ \snippet tutorials/notepad/notepad.h all
+
+ The following line includes QMainWindow that provides a main application
+ window:
+
+ \snippet tutorials/notepad/notepad.h 1
+
+ The following lines declare the Notepad class in the Ui namespace,
+ which is the standard namespace for the UI classes generated from
+ .ui files by the \c uic tool:
+
+ \snippet tutorials/notepad/notepad.h 2
+
+ The class declaration contains the \c Q_OBJECT macro. It must come
+ first in the class definition, and declares our class as a QObject.
+ Naturally, it must also inherit from QObject. A QObject adds several
+ abilities to a normal C++ class. Notably, the class name and slot
+ names can be queried at runtime. It is also possible to query a slot's
+ parameter types and invoke it.
+
+ \snippet tutorials/notepad/notepad.h 3
+
+ The following lines declare a constructor that has a default argument
+ called \c parent.
+ The value 0 indicates that the widget has no parent (it is a top-level
+ widget).
+
+ \snippet tutorials/notepad/notepad.h 4
+
+ The following line declares a virtual destructor to free the resources
+ that were acquired by the object during its life-cycle. According to
+ the C++ naming convention, destructors have the same name as the class
+ they are associated with, prefixed with a tilde (~). In QObject,
+ destructors are virtual to ensure that the destructors of derived
+ classes are invoked properly when an object is deleted through a
+ pointer-to-base-class.
+
+ \snippet tutorials/notepad/notepad.h 5
+
+ The following lines declare a member variable which is a pointer to
+ the Notepad UI class. A member variable is associated with a specific
+ class, and accessible for all its methods.
+
+ \snippet tutorials/notepad/notepad.h 6
+
+ \section2 Notepad Source File
+
+ The source file that the wizard generated for the Notepad class looks
+ as follows:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto notepad.h
+ \printuntil ui->textEdit->setFont(font)
+ \printuntil }
+
+ The following lines include the Notepad class header file that was
+ generated by the wizard and the UI header file that was generated
+ by the \c uic tool:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto notepad.h
+ \printuntil ui_notepad
+
+ The following line defines the \c {Notepad} constructor:
+
+ \skipto Notepad::Notepad
+ \printline Notepad::Notepad
+
+ The following line calls the QMainWindow constructor, which is
+ the base class for the Notepad class:
+
+ \printline QMainWindow
+
+ The following line creates the UI class instance and assigns it to
+ the \c ui member:
+
+ \printline ui(new
+
+ The following line sets up the UI:
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto ui->setupUi
+ \printline ui->setupUi(this)
+
+ In the destructor, we delete the \c ui:
+
+ \skipto Notepad::~Notepad
+ \printuntil }
+
+ In order to have the text edit field occupy the whole screen, we add
+ \c setCentralWidget to the main window.
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto Notepad::Notepad(QWidget *parent)
+ \printuntil }
+
+ \section2 Project File
+
+ The wizard generates the following project file, \c {notepad.pro}, for
+ us:
+
+ \quotefile tutorials/notepad/notepad.pro
+
+ The project file specifies the application name and the \c qmake
+ template to use for generating the project, as well as the source,
+ header, and UI files included in the project.
+
+ You could also use \c qmake's \c -project option to generate the \.pro
+ file. Although, in that case, you have to remember to add the line
+ \c{QT += widgets} to the generated file in order to link against the
+ Qt Widgets Module.
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li Using Qt Designer
+ \li \l{Qt Designer Manual}
+ \row
+ \li Layouts
+ \li \l{Layout Management},
+ \l{Widgets and Layouts},
+ \l{Layout Examples}
+ \row
+ \li The widgets that come with Qt
+ \li \l{Qt Widget Gallery}
+ \row
+ \li Main windows and main window classes
+ \li \l{Application Main Window},
+ \l{Main Window Examples}
+ \row
+ \li QObjects and the Qt Object model (This is essential to
+ understand Qt)
+ \li \l{Object Model}
+ \row
+ \li qmake and the Qt build system
+ \li \l{qmake Manual}
+ \endtable
+
+ \section1 Adding User Interaction
+
+
+ To add functionality to the editor, we start by adding menu items
+ and buttons on a toolbar.
+
+ Click on "Type Here", and add the options New, Open, Save, Save as,
+ Print and Exit. This creates 5 lines in the Action Editor below.
+ To connect the actions to slots, right-click an action and select
+ Go to slot > triggered(), and complete the code for that given slot.
+
+ If we also want to add the actions to a toolbar, we can assign an
+ icon to each QAction, and then drag the QAction to the toolbar. You
+ assign an icon by entering an icon name in the Icon property of the
+ action concerned. When the QAction has been dragged to the toolbar,
+ clicking the icon will launch the associated slot.
+
+ Complete the method \c on_actionNew_triggered():
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto on_actionNew_triggered()
+ \printuntil }
+
+ \c current_file is a global variable containing the file presently
+ being edited.
+ It is defined in the private part of notepad.h:
+
+ \quotefromfile tutorials/notepad/notepad.h
+ \skipto private:
+ \printuntil currentFile;
+
+ \c clear() clears the text buffer.
+
+ \section2 Opening a file
+
+ In \c notepad.ui, right click on \c actionOpen and select \c {Go to
+ slot}
+
+ Complete method \c on_actionOpen_triggered().
+
+ \quotefromfile tutorials/notepad/notepad.cpp
+ \skipto on_actionOpen_triggered()
+ \printuntil file.close
+ \printuntil }
+
+
+ \c QFileDialog::getOpenFileName opens a dialog enabling you to select
+ a file. QFile object \c myfile has the selected \c file_name as
+ parameter. We store the selected file also into the global variable
+ \c current_file for later purposes. We open the file with \c file.open
+ as a readonly text file. If it cannot be opened, a warning is issued,
+ and the program stops.
+
+ We define a QTextStream \c instream for parameter \c myfile.
+ The contents of file \c myfile is copied into QString \a text.
+ \c setText(text) fille the buffer of our editor with \c text.
+
+ \c section2 Saving a file
+
+ We create the method for saving a file in the same way as for
+ \l {Opening a file}, by right clicking on \c actionSave, and
+ selecting \c {Go to Slot}.
+
+ \skipto Notepad::on_actionSave_triggered
+ \printuntil file.close
+ \printuntil }
+
+ QFile object \c myfile is linked to global variable \c current_file,
+ the variable that contains the file we were working with.
+ If we cannot open \c myfile, an error message is issued and the
+ method stops. We create a QTextStream \c outstream. The contents
+ of the editor buffer is converted to plain text, and then written
+ to \c outstream.
+
+ \section2 Saving a file with \c {Save as}
+
+ \skipto Notepad::on_actionSave_as_triggered
+ \printuntil file.close
+ \printuntil }
+
+ This is the same procedure as for \c {Saving a file}, the only
+ difference being that here you need to enter a new file name for
+ the file to be created.
+
+
+ \section2 Print a File
+
+ If you want to use print functionalities, you need to add
+ \c printsupport to the project file:
+
+ \badcode
+ QT += printsupport
+ \endcode
+
+ We declare a QPrinter object called \c printer.
+ We launch a printer dialog box and store the selected printer in
+ object \c printer. If we clicked on \c Cancel and did not select
+ a printer, the methods returns. The actual printer command is given
+ with \a ui->textEdit->print with our QPrinter object as parameter.
+
+ \section2 Select a Font
+
+ \skipto Notepad::on_actionFont_triggered
+ \printuntil ui->textEdit->setFont
+ \printline }
+
+ We declare a boolean indicating if we did select a font with
+ QFontDialog. If so, we set the font with \c ui->textEdit->setFont(myfont).
+
+ \section2 Copy, Cut, Paste, Undo, and Redo
+
+ If you select some text, and want to copy it to the clipboard,
+ you call the appropriate method of ui->textEdit. The same counts
+ for cut, paste, undo, and redo.
+
+ This table shows the method name to use.
+
+ \table
+ \header
+ \li Task
+ \li Method called
+ \row
+ \li Copy
+ \li ui->textEdit->copy()
+ \row
+ \li Cut
+ \li ui->textEdit->cut()
+ \row
+ \li Paste
+ \li ui->textEdit->paste()
+ \row
+ \li Undo
+ \li ui->textEdit->undo()
+ \row
+ \li Redo
+ \li ui->textEdit->redo()
+ \endtable
+
+ \b{Learn More}
+
+ \table
+ \header
+ \li About
+ \li Here
+ \row
+ \li MDI applications
+ \li QMdiArea,
+ \l{MDI Example}
+ \row
+ \li Files and I/O devices
+ \li QFile, QIODevice
+ \row
+ \li tr() and internationalization
+ \li \l{Qt Linguist Manual},
+ \l{Writing Source Code for Translation},
+ \l{Internationalization with Qt}
+ \endtable
+
+ \section1 Building and Running Notepad
+
+ Now that you have all the necessary files, select \b Build >
+ \b {Build Project Notepad} to build and run the application. Qt
+ Creator uses \c qmake and \c make to create an executable in the
+ directory specified in the build settings of the project and runs
+ it.
+
+ \section2 Building and Running from the Command Line
+
+ To build the application from the command line, switch to the
+ directory in which you have the \c .cpp file of the application
+ and add the project file (suffixed .pro) described earlier. The
+ following shell commands then build the application:
+
+ \badcode
+ qmake
+ make (or nmake on Windows)
+ \endcode
+
+ The commands create an executable in the project directory. The
+ \c qmake tool reads the project file and produces a \c Makefile
+ with instructions on how to build the application.
+ The \c make tool (or the \c nmake tool) then reads the \c Makefile
+ and produces the executable binary.
+*/
diff --git a/examples/widgets/tutorials/notepad/images/copy.png b/examples/widgets/tutorials/notepad/images/copy.png
new file mode 100644
index 0000000000..cb3442c04c
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/copy.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/create.png b/examples/widgets/tutorials/notepad/images/create.png
new file mode 100644
index 0000000000..fdfd4b438a
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/create.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/cut.png b/examples/widgets/tutorials/notepad/images/cut.png
new file mode 100644
index 0000000000..74b15301ff
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/cut.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/edit_redo.png b/examples/widgets/tutorials/notepad/images/edit_redo.png
new file mode 100644
index 0000000000..8a7725463c
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/edit_redo.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/edit_undo.png b/examples/widgets/tutorials/notepad/images/edit_undo.png
new file mode 100644
index 0000000000..852f5e3b29
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/edit_undo.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/exit.png b/examples/widgets/tutorials/notepad/images/exit.png
new file mode 100644
index 0000000000..677d4deef2
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/exit.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/font.png b/examples/widgets/tutorials/notepad/images/font.png
new file mode 100644
index 0000000000..925e501c03
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/font.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/info.png b/examples/widgets/tutorials/notepad/images/info.png
new file mode 100644
index 0000000000..9731212c4f
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/info.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/new.png b/examples/widgets/tutorials/notepad/images/new.png
new file mode 100644
index 0000000000..b24edc5d0c
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/new.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/open.png b/examples/widgets/tutorials/notepad/images/open.png
new file mode 100644
index 0000000000..7b052edf5a
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/open.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/paste.png b/examples/widgets/tutorials/notepad/images/paste.png
new file mode 100644
index 0000000000..c50dbd95b2
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/paste.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/pencil.png b/examples/widgets/tutorials/notepad/images/pencil.png
new file mode 100644
index 0000000000..a9c5e5482a
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/pencil.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/print.png b/examples/widgets/tutorials/notepad/images/print.png
new file mode 100644
index 0000000000..0cd3f28bd8
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/print.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/save.png b/examples/widgets/tutorials/notepad/images/save.png
new file mode 100644
index 0000000000..e65a29d5f1
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/save.png
Binary files differ
diff --git a/examples/widgets/tutorials/notepad/images/save_as.png b/examples/widgets/tutorials/notepad/images/save_as.png
new file mode 100644
index 0000000000..6040574322
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/images/save_as.png
Binary files differ
diff --git a/examples/widgets/dialogs/configdialog/main.cpp b/examples/widgets/tutorials/notepad/main.cpp
index e73474b866..20bcdaa7df 100644
--- a/examples/widgets/dialogs/configdialog/main.cpp
+++ b/examples/widgets/tutorials/notepad/main.cpp
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,16 +48,14 @@
**
****************************************************************************/
+#include "notepad.h"
#include <QApplication>
-#include "configdialog.h"
-
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(configdialog);
+ QApplication EditorApp(argc, argv);
+ Notepad Editor;
+ Editor.show();
- QApplication app(argc, argv);
- app.setApplicationDisplayName("Qt Example");
- ConfigDialog dialog;
- return dialog.exec();
+ return EditorApp.exec();
}
diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp
new file mode 100644
index 0000000000..b4f6cf7f8f
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/notepad.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QFileDialog>
+#include <QTextStream>
+#include <QMessageBox>
+#include <QPrintDialog>
+#include <QPrinter>
+#include <QFont>
+#include <QFontDialog>
+
+#include "notepad.h"
+#include "ui_notepad.h"
+
+Notepad::Notepad(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::Notepad)
+{
+ ui->setupUi(this);
+ this->setCentralWidget(ui->textEdit);
+}
+
+Notepad::~Notepad()
+{
+ delete ui;
+}
+
+void Notepad::on_actionNew_triggered()
+{
+ currentFile.clear();
+ ui->textEdit->setText(QString());
+}
+
+void Notepad::on_actionOpen_triggered()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
+ QFile file(fileName);
+ currentFile = fileName;
+ if (!file.open(QIODevice::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, "Warning", "Cannot open file: " + file.errorString());
+ return;
+ }
+ setWindowTitle(fileName);
+ QTextStream in(&file);
+ QString text = in.readAll();
+ ui->textEdit->setText(text);
+ file.close();
+}
+
+void Notepad::on_actionSave_triggered()
+{
+ QString fileName;
+ // If we don't have a filename from before, get one.
+ if (currentFile.isEmpty()) {
+ fileName = QFileDialog::getSaveFileName(this, "Save");
+ currentFile = fileName;
+ } else {
+ fileName = currentFile;
+ }
+ QFile file(fileName);
+ if (!file.open(QIODevice::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
+ return;
+ }
+ setWindowTitle(fileName);
+ QTextStream out(&file);
+ QString text = ui->textEdit->toPlainText();
+ out << text;
+ file.close();
+}
+
+void Notepad::on_actionSave_as_triggered()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, "Save as");
+ QFile file(fileName);
+
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
+ return;
+ }
+ currentFile = fileName;
+ setWindowTitle(fileName);
+ QTextStream out(&file);
+ QString text = ui->textEdit->toPlainText();
+ out << text;
+ file.close();
+}
+
+void Notepad::on_actionPrint_triggered()
+{
+ QPrinter printDev;
+ QPrintDialog dialog(&printDev, this);
+ if (dialog.exec() == QDialog::Rejected)
+ return;
+ ui->textEdit->print(&printDev);
+}
+
+void Notepad::on_actionExit_triggered()
+{
+ QCoreApplication::quit();
+}
+
+void Notepad::on_actionCopy_triggered()
+{
+ ui->textEdit->copy();
+}
+
+void Notepad::on_actionCut_triggered()
+{
+ ui->textEdit->cut();
+}
+
+void Notepad::on_actionPaste_triggered()
+{
+ ui->textEdit->paste();
+}
+
+void Notepad::on_actionUndo_triggered()
+{
+ ui->textEdit->undo();
+}
+
+void Notepad::on_actionRedo_triggered()
+{
+ ui->textEdit->redo();
+}
+
+void Notepad::on_actionFont_triggered()
+{
+ bool fontSelected;
+ QFont font = QFontDialog::getFont(&fontSelected, this);
+ if (fontSelected)
+ ui->textEdit->setFont(font);
+}
diff --git a/examples/widgets/dialogs/configdialog/configdialog.h b/examples/widgets/tutorials/notepad/notepad.h
index c2edd204e6..f688df45ac 100644
--- a/examples/widgets/dialogs/configdialog/configdialog.h
+++ b/examples/widgets/tutorials/notepad/notepad.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the examples of the Qt Toolkit.
+** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,32 +48,67 @@
**
****************************************************************************/
-#ifndef CONFIGDIALOG_H
-#define CONFIGDIALOG_H
+#ifndef NOTEPAD_H
+#define NOTEPAD_H
-#include <QDialog>
+//! [all]
+//! [1]
+#include <QMainWindow>
+//! [1]
+//! [2]
QT_BEGIN_NAMESPACE
-class QListWidget;
-class QListWidgetItem;
-class QStackedWidget;
+namespace Ui {
+class Notepad;
+}
QT_END_NAMESPACE
+//! [2]
-class ConfigDialog : public QDialog
+//! [3]
+class Notepad : public QMainWindow
{
Q_OBJECT
+//! [3]
+//! [4]
public:
- ConfigDialog();
+ explicit Notepad(QWidget *parent = 0);
+//! [4]
+//! [5]
+ ~Notepad();
+//! [5]
-public slots:
- void changePage(QListWidgetItem *current, QListWidgetItem *previous);
+private slots:
+ void on_actionNew_triggered();
-private:
- void createIcons();
+ void on_actionOpen_triggered();
+
+ void on_actionSave_triggered();
+
+ void on_actionSave_as_triggered();
+
+ void on_actionPrint_triggered();
+
+ void on_actionExit_triggered();
+
+ void on_actionCopy_triggered();
- QListWidget *contentsWidget;
- QStackedWidget *pagesWidget;
+ void on_actionCut_triggered();
+
+ void on_actionPaste_triggered();
+
+ void on_actionUndo_triggered();
+
+ void on_actionRedo_triggered();
+
+ void on_actionFont_triggered();
+
+//! [6]
+private:
+ Ui::Notepad *ui;
+ QString currentFile;
+//! [6]
};
+//! [all]
-#endif
+#endif // NOTEPAD_H
diff --git a/examples/widgets/tutorials/notepad/notepad.pro b/examples/widgets/tutorials/notepad/notepad.pro
new file mode 100644
index 0000000000..7369dbc991
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/notepad.pro
@@ -0,0 +1,20 @@
+TEMPLATE = app
+TARGET = notepad
+
+QT += printsupport
+
+SOURCES += \
+ main.cpp\
+ notepad.cpp
+
+HEADERS += notepad.h
+
+FORMS += notepad.ui
+
+RESOURCES += \
+ notepad.qrc
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/notepad
+INSTALLS += target
+
diff --git a/examples/widgets/tutorials/notepad/notepad.qrc b/examples/widgets/tutorials/notepad/notepad.qrc
new file mode 100644
index 0000000000..ec11679f13
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/notepad.qrc
@@ -0,0 +1,19 @@
+<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>
+ <file>images/paste.png</file>
+ <file>images/pencil.png</file>
+ <file>images/print.png</file>
+ <file>images/save.png</file>
+ <file>images/save_as.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui
new file mode 100644
index 0000000000..d197a95fe7
--- /dev/null
+++ b/examples/widgets/tutorials/notepad/notepad.ui
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Notepad</class>
+ <widget class="QMainWindow" name="Notepad">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>524</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Notepad</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="textEdit"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>524</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="actionNew"/>
+ <addaction name="actionOpen"/>
+ <addaction name="actionSave"/>
+ <addaction name="actionSave_as"/>
+ <addaction name="actionPrint"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
+ <widget class="QMenu" name="menuEdit">
+ <property name="title">
+ <string>Edit</string>
+ </property>
+ <addaction name="actionCopy"/>
+ <addaction name="actionCut"/>
+ <addaction name="actionPaste"/>
+ <addaction name="separator"/>
+ <addaction name="actionUndo"/>
+ <addaction name="actionRedo"/>
+ <addaction name="actionFont"/>
+ </widget>
+ <addaction name="menuFile"/>
+ <addaction name="menuEdit"/>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ <addaction name="actionNew"/>
+ <addaction name="actionOpen"/>
+ <addaction name="actionSave"/>
+ <addaction name="actionSave_as"/>
+ <addaction name="actionPrint"/>
+ <addaction name="separator"/>
+ <addaction name="actionCopy"/>
+ <addaction name="actionCut"/>
+ <addaction name="actionPaste"/>
+ <addaction name="actionUndo"/>
+ <addaction name="actionRedo"/>
+ <addaction name="actionFont"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <action name="actionNew">
+ <property name="icon">
+ <iconset resource="notepad.qrc">
+ <normaloff>:/images/new.png</normaloff>:/images/new.png</iconset>
+ </property>
+ <property name="text">
+ <string>New</string>
+ </property>
+ </action>
+ <action name="actionOpen">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
+ </property>
+ <property name="text">
+ <string>Open</string>
+ </property>
+ </action>
+ <action name="actionSave">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
+ </property>
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </action>
+ <action name="actionSave_as">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset>
+ </property>
+ <property name="text">
+ <string>Save as</string>
+ </property>
+ </action>
+ <action name="actionPrint">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
+ </property>
+ <property name="text">
+ <string>Print</string>
+ </property>
+ </action>
+ <action name="actionExit">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
+ </property>
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ <action name="actionCopy">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
+ </property>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ </action>
+ <action name="actionCut">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
+ </property>
+ <property name="text">
+ <string>Cut</string>
+ </property>
+ </action>
+ <action name="actionPaste">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
+ </property>
+ <property name="text">
+ <string>Paste</string>
+ </property>
+ </action>
+ <action name="actionUndo">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset>
+ </property>
+ <property name="text">
+ <string>Undo</string>
+ </property>
+ </action>
+ <action name="actionRedo">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset>
+ </property>
+ <property name="text">
+ <string>Redo</string>
+ </property>
+ </action>
+ <action name="actionFont">
+ <property name="icon">
+ <iconset>
+ <normaloff>:/images/font.png</normaloff>:/images/font.png</iconset>
+ </property>
+ <property name="text">
+ <string>Font</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources>
+ <include location="notepad.qrc"/>
+ </resources>
+ <connections/>
+</ui>
diff --git a/examples/widgets/tutorials/tutorials.pro b/examples/widgets/tutorials/tutorials.pro
index 2eb87cdbd5..0aaa119d8f 100644
--- a/examples/widgets/tutorials/tutorials.pro
+++ b/examples/widgets/tutorials/tutorials.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS += addressbook widgets modelview gettingStarted
+SUBDIRS += addressbook widgets modelview gettingStarted notepad