path: root/examples/widgets
diff options
Diffstat (limited to 'examples/widgets')
5 files changed, 101 insertions, 52 deletions
diff --git a/examples/widgets/doc/src/addressbook-tutorial.qdoc b/examples/widgets/doc/src/addressbook-tutorial.qdoc
index 31d1d64dac..1f6966e8ae 100644
--- a/examples/widgets/doc/src/addressbook-tutorial.qdoc
+++ b/examples/widgets/doc/src/addressbook-tutorial.qdoc
@@ -80,7 +80,7 @@
\example tutorials/addressbook/part1
\title Part 1 - Designing the User Interface
+ \brief Describes how to code the user interface of the Address Book Example.
This first part covers the design of the basic graphical user
interface (GUI) for our address book application.
@@ -232,6 +232,7 @@
\example tutorials/addressbook/part2
\title Part 2 - Adding Addresses
+ \brief Describes the code for inserting records in the Address Book Example.
The next step in creating the address book is to implement some
user interactions.
@@ -381,9 +382,10 @@
\example tutorials/addressbook/part3
\title Part 3 - Navigating between Entries
+ \brief Explains the code that enables navigating the contacts.
The address book is now about half complete. We should add the
- capability to navigate among the contacts, but first we must
+ capability to navigate the contacts, but first we must
decide what sort of a data structure we need for containing these
@@ -496,6 +498,7 @@
\example tutorials/addressbook/part4
\title Part 4 - Editing and Removing Addresses
+ \brief Explains how to add edit and remove functionality.
Now we look at ways to modify the contents of contacts stored in
the address book.
@@ -628,6 +631,7 @@
\example tutorials/addressbook/part5
\title Part 5 - Adding a Find Function
+ \brief Describes how to add a find function.
Here we look at ways to locate contacts and addresses in the
address book.
@@ -770,6 +774,7 @@
\example tutorials/addressbook/part6
\title Part 6 - Loading and Saving
+ \brief Describes how to add save and load functionality.
This part covers the Qt file handling features we use to write
loading and saving routines for the address book.
@@ -890,6 +895,7 @@
\example tutorials/addressbook/part7
\title Part 7 - Additional Features
+ \brief Describes how to export data in VCard format.
This part covers some additional features that make the address
book more convenient for the frequent user.
diff --git a/examples/widgets/doc/src/eventtransitions.qdoc b/examples/widgets/doc/src/eventtransitions.qdoc
index 2c59d0863d..4d332c0e00 100644
--- a/examples/widgets/doc/src/eventtransitions.qdoc
+++ b/examples/widgets/doc/src/eventtransitions.qdoc
@@ -29,17 +29,29 @@
\example statemachine/eventtransitions
\title Event Transitions Example
- \brief The Event Transitions example shows how to use event transitions, a
- feature of \l{The State Machine Framework}.
+ \brief The Event Transitions example shows how to use event transitions,
+ a feature of \l{The State Machine Framework}.
+ The Event Transitions Example illustrates how states change when a
+ user enters or leaves the area of a button. The states are handled by
+ a QStateMachine object. The screen consists of a QVBoxLayout with a
+ central button.
+ When the mouse is outside the button, the text in the button displays
+ "Outside". When the mouse enters the button, it displays "Inside".
+ \borderedimage transitions.png
\snippet statemachine/eventtransitions/main.cpp 0
The \c Window class's constructors begins by creating a button.
+ This button is added to \c layout, which is a QVBoxLayout object.
+ Then two states are created: \s1 is the state
+ "Outside", and \c s2 is the state "Inside".
\snippet statemachine/eventtransitions/main.cpp 1
- Two states, \c s1 and \c s2, are created; upon entry they will assign
- "Outside" and "Inside" to the button's text, respectively.
+ State \c s1 is the state "Outside" and state \c s2 is state "Inside".
\snippet statemachine/eventtransitions/main.cpp 2
@@ -54,11 +66,11 @@
\snippet statemachine/eventtransitions/main.cpp 4
- Next, the state \c s3 is created. \c s3 will be entered when the button
+ Next, state \c s3 is created. \c s3 will be entered when the button
receives an event of type QEvent::MouseButtonPress and the state machine
is in state \c s2. When the button receives an event of type
QEvent::MouseButtonRelease and the state machine is in state \c s3, the
- machine will transition back to state \c s2.
+ machine will revert to state \c s2.
\snippet statemachine/eventtransitions/main.cpp 5
@@ -67,6 +79,7 @@
\snippet statemachine/eventtransitions/main.cpp 6
- The main() function constructs a Window object and shows it.
+ The main() function constructs a Window object that displays the QVBoxLayout
+ object \c layout with its \c button.
diff --git a/examples/widgets/doc/src/findfiles.qdoc b/examples/widgets/doc/src/findfiles.qdoc
index a2eb326519..ad39b003ae 100644
--- a/examples/widgets/doc/src/findfiles.qdoc
+++ b/examples/widgets/doc/src/findfiles.qdoc
@@ -30,43 +30,74 @@
\title Find Files Example
\ingroup examples-dialogs
- \brief The Find Files example shows how to use QProgressDialog to provide
- feedback on the progress of a slow operation. The example also
- shows how to use QFileDialog to facilitate browsing, how to use
- QTextStream's streaming operators to read a file, and how to use
- QTableWidget to provide standard table display facilities for
- applications. In addition, files can be opened using the
- QDesktopServices class.
+ \brief A dialog for finding files in a specified folder
+ The Find Files application allows the user to search for files in a
+ specified directory, matching a given file name or wildcard,
+ and containing a specified string (if filled in). The search
+ result is displayed in a table containing the names of the files
+ and their sizes. The application also shows the number of files found.
+ The Find Files example illustrates the use of several classes:
+ \table
+ \row
+ \li QProgressDialog
+ \li Provide feedback on the progress of a search operation
+ \row
+ \li QFileDialog
+ \li Browse through a file list
+ \row
+ \li QTextStream
+ \li Use stream operators to read a file
+ \row
+ \li QTableWidget
+ \li Browse through the search results in a table
+ \row
+ \li QDesktopServices
+ \li Open files in the result list in a suitable application
+ \endtable
\image findfiles-example.png Screenshot of the Find Files example
- With the Find Files application the user can search for files in a
- specified directory, matching a specified file name (using wild
- cards if appropriate) and containing a specified text.
- The user is provided with a \uicontrol Browse option, and the result of
- the search is displayed in a table with the names of the files
- found and their sizes. In addition the application provides a
- total count of the files found.
\section1 Window Class Definition
The \c Window class inherits QWidget, and is the main application
- widget. It shows the search options, and displays the search
+ widget. It shows the search options and displays the search
\snippet dialogs/findfiles/window.h 0
- We need two private slots: The \c browse() slot is called whenever
- the user wants to browse for a directory to search in, and the \c
- find() slot is called whenever the user requests a search to be
- performed by pressing the \uicontrol Find button.
- In addition we declare several private functions: We use the \c
- findFiles() function to search for files matching the user's
- specifications, we call the \c showFiles() function to display the
- results, and we use \c createButton(), \c createComboBox() and \c
- createFilesTable() when we are constructing the widget.
+ The application has two private slots:
+ \table
+ \row
+ \li The \c browse() slot
+ \li Called whenever the user wants to browse for a directory to search in
+ \row
+ \li The \c find() slot
+ \li Called whenever the user launches a search with the \uicontrol Find button
+ \endtable
+ In addition we declare several private functions:
+ \table
+ \row
+ \li findFiles()
+ \li Search for files matching the search parameters
+ \row
+ \li showFiles()
+ \li Display the search result
+ \row
+ \li ceateButton()
+ \li Construct the widget
+ \row
+ \li createComboBox()
+ \li Construct the widget
+ \row
+ \li createFilesTable()
+ \li Construct the widget
+ \endtable
\section1 Window Class Implementation
@@ -103,11 +134,11 @@
Here we use the static QFileDialog::getExistingDirectory()
function which returns an existing directory selected by the
user. Then we display the directory in the directory combobox
- using the QComboBox::addItem() function, and updates the current
+ using the QComboBox::addItem() function and update the current
QComboBox::addItem() adds an item to the combobox with the given
- text (if it is not already present in the list), and containing
+ text (if not already present in the list), and containing
the specified userData. The item is appended to the list of
existing items.
@@ -118,13 +149,13 @@
First we eliminate any previous search results by setting the
table widgets row count to zero. Then we retrieve the
- specified file name, text and directory path from the respective
+ specified file name, text, and directory path from the respective
\snippet dialogs/findfiles/window.cpp 4
We use the directory's path to create a QDir; the QDir class
- provides access to directory structures and their contents.
+ provides access to the directory structure and its contents.
We use QDirIterator to iterate over the files that match the
specified file name and build a QStringList of paths.
@@ -144,15 +175,11 @@
In the private \c findFiles() function we search through a list of
files, looking for the ones that contain a specified text. This
can be a very slow operation depending on the number of files as
- well as their sizes. In case there are a large number of files, or
- there exists some large files on the list, we provide a
- QProgressDialog.
- The QProgressDialog class provides feedback on the progress of a
- slow operation. It is used to give the user an indication of how
- long an operation is going to take, and to demonstrate that the
- application has not frozen. It can also give the user an
- opportunity to abort the operation.
+ well as their sizes. QProgressDialog displays a progress dialog
+ if the application has to search through a large number of files,
+ or if some of the files have a large size. QProgressDialog can
+ also allow the user to abort the operation if it takes too much
+ time.
\snippet dialogs/findfiles/window.cpp 6
diff --git a/examples/widgets/tools/i18n/languagechooser.cpp b/examples/widgets/tools/i18n/languagechooser.cpp
index 83aafe6b8a..58cf9d4047 100644
--- a/examples/widgets/tools/i18n/languagechooser.cpp
+++ b/examples/widgets/tools/i18n/languagechooser.cpp
@@ -70,7 +70,10 @@ LanguageChooser::LanguageChooser(const QString& defaultLang, QWidget *parent)
for (int i = 0; i < qmFiles.size(); ++i) {
QCheckBox *checkBox = new QCheckBox(languageName(qmFiles[i]));
qmFileForCheckBoxMap.insert(checkBox, qmFiles[i]);
- connect(checkBox, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled()));
+ connect(checkBox,
+ QOverload<bool>::of(&QCheckBox::toggled),
+ this,
+ &LanguageChooser::checkBoxToggled);
if (languageMatch(defaultLang, qmFiles[i]))
groupBoxLayout->addWidget(checkBox, i / 2, i % 2);
@@ -84,8 +87,8 @@ LanguageChooser::LanguageChooser(const QString& defaultLang, QWidget *parent)
hideAllButton = buttonBox->addButton("Hide All",
- connect(showAllButton, SIGNAL(clicked()), this, SLOT(showAll()));
- connect(hideAllButton, SIGNAL(clicked()), this, SLOT(hideAll()));
+ connect(showAllButton, &QAbstractButton::clicked, this, &LanguageChooser::showAll);
+ connect(hideAllButton, &QAbstractButton::clicked, this, &LanguageChooser::hideAll);
QVBoxLayout *mainLayout = new QVBoxLayout;
diff --git a/examples/widgets/tools/i18n/mainwindow.cpp b/examples/widgets/tools/i18n/mainwindow.cpp
index d5de81cab7..6ebfddfa98 100644
--- a/examples/widgets/tools/i18n/mainwindow.cpp
+++ b/examples/widgets/tools/i18n/mainwindow.cpp
@@ -76,7 +76,7 @@ MainWindow::MainWindow()
exitAction = new QAction(tr("E&xit"), this);
- connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+ connect(exitAction, &QAction::triggered, qApp, QApplication::quit);
fileMenu = menuBar()->addMenu(tr("&File"));