summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeena Miettinen <riitta-leena.miettinen@qt.io>2022-01-14 17:03:29 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-24 16:28:44 +0000
commit000e26a4d5ab66b532146e66333e1c72859bdc52 (patch)
tree265b6b275b13f22370131581db131f6dd7044467
parentb0aa0860f3f012a7d4740ed1d69b355a61aa3624 (diff)
downloadqtdoc-000e26a4d5ab66b532146e66333e1c72859bdc52.tar.gz
Update Qt Quick GS tutorial
- Update information about and screenshots of Qt Creator New Project wizard template. - Use the main.cpp file generated by Qt Creator 7.0 Fixes: QTBUG-99847 Change-Id: I1c2208267e9554e2f929ffffaa3dabd5554fc12e Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 302121874ea6e664ea2a59a07bff8fa06983c335) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--doc/src/getting-started/gettingstartedqml.qdoc36
-rw-r--r--doc/src/images/alarms2.pngbin24310 -> 12543 bytes
-rw-r--r--doc/src/images/alarms3.pngbin14194 -> 10255 bytes
-rw-r--r--examples/tutorials/alarms/main.cpp11
4 files changed, 28 insertions, 19 deletions
diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc
index 1d033139..5ff64c35 100644
--- a/doc/src/getting-started/gettingstartedqml.qdoc
+++ b/doc/src/getting-started/gettingstartedqml.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -31,7 +31,7 @@
\brief A tutorial for Qt Quick based on an alarms application.
This tutorial shows how to develop a simple alarm application as
- an introduction to Qt Quick and Qt Quick Controls2.
+ an introduction to Qt Quick and Qt Quick Controls.
This application is similar to the alarm application usually
found on an Android phone. Its features let you enter, edit,
@@ -65,6 +65,9 @@
The latter two files are included with the source code for this
tutorial.
+ \note The UI text in Qt Creator and the contents of the generated files
+ depend on the Qt Creator version that you use.
+
\section1 Qt Creator
Setting up a new project in Qt Creator is aided by a wizard that
@@ -73,12 +76,12 @@
type of project and creates the project for you.
To create the Alarms project, select \uicontrol{File} >
- \uicontrol{New File or Project} > \uicontrol{Application} >
- \uicontrol{Qt Quick Application - Empty} > \uicontrol{Choose}.
- Type "alarms" in the \b{Name} field, and follow the instructions
+ \uicontrol{New Project} > \uicontrol{Application (Qt)} >
+ \uicontrol{Qt Quick Application} > \uicontrol{Choose}.
+ Type \e alarms in the \uicontrol{Name} field, and follow the instructions
of the wizard.
- \image alarms2.png "Qt Creator New File or Project dialog"
+ \image alarms2.png "Qt Creator New Project dialog"
\image alarms3.png "Project Location"
@@ -90,15 +93,16 @@
\li Source file
\li Purpose
\row
- \li alarms.pro
+ \li CMakeLists.txt
\li The project file
\row
\li main.cpp
\li The main C++ code file for the application.
- \row
- \li qml.qrc
- \li The resource file, which contains the names of the
- source files, except main.cpp and the project file.
+ \row
+ \li main.qml
+ \li The main QML code file for the application. We will instantiate
+ our custom QML types (\c AlarmDialog, \c AlarmModel,
+ \c AlarmDelegate, and \c TumblerDelegate) in this file.
\endtable
The wizard generates the code in the main.cpp file below.
@@ -119,10 +123,6 @@
\li \c qtquickcontrols2.conf
\li Selects the \c Material style with the \c Dark theme.
\row
- \li \c main.qml
- \li The QML code that links AlarmDialog.qml, AlarmModel.qml,
- AlarmDelegate.qml and TumblerDelegate.qml
- \row
\li \c AlarmDialog.qml
\li Defines the dialog for adding new alarms.
\row
@@ -133,7 +133,11 @@
\li Defines the ListModel used for storing the alarms' data.
\row
\li \c TumblerDelegate.qml
- \li Defines the graphical layout of the Tumblers
+ \li Defines the graphical layout of the Tumblers.
+ \row
+ \li \c qml.qrc
+ \li The resource file, which contains the names of the
+ source files, except main.cpp and the project file.
\endtable
diff --git a/doc/src/images/alarms2.png b/doc/src/images/alarms2.png
index dbcb852c..a81a36d2 100644
--- a/doc/src/images/alarms2.png
+++ b/doc/src/images/alarms2.png
Binary files differ
diff --git a/doc/src/images/alarms3.png b/doc/src/images/alarms3.png
index 48abec6a..d680a4ed 100644
--- a/doc/src/images/alarms3.png
+++ b/doc/src/images/alarms3.png
Binary files differ
diff --git a/examples/tutorials/alarms/main.cpp b/examples/tutorials/alarms/main.cpp
index 3e1bdd84..04d2f8dc 100644
--- a/examples/tutorials/alarms/main.cpp
+++ b/examples/tutorials/alarms/main.cpp
@@ -57,9 +57,14 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
- if (engine.rootObjects().isEmpty())
- return -1;
+ const QUrl url(u"qrc:/alarms/main.qml"_qs);
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app,
+ [url](QObject *obj, const QUrl &objUrl) {
+ if (!obj && url == objUrl)
+ QCoreApplication::exit(-1);
+ },
+ Qt::QueuedConnection);
+ engine.load(url);
return app.exec();
}