2011-12-14 15:07:05 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-12-14 15:07:05 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** This file is part of the Qt Creator documentation.
|
2011-12-14 15:07:05 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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.
|
2011-12-14 15:07:05 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** GNU Free Documentation License Usage
|
2011-12-14 15:07:05 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
2016-01-15 14:51:16 +01:00
|
|
|
** 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.
|
2011-12-14 15:07:05 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// NOTE: the sections are not ordered by their logical order to avoid
|
|
|
|
|
// reshuffling the file each time the index order changes (i.e., often).
|
|
|
|
|
// Run the fixnavi.pl script to adjust the links to the index order.
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
2014-03-17 12:18:12 +01:00
|
|
|
\contentspage {Qt Creator Manual}
|
2011-12-14 15:07:05 +01:00
|
|
|
\previouspage creator-visual-editor.html
|
|
|
|
|
\page quick-projects.html
|
2014-10-28 15:18:01 +01:00
|
|
|
\nextpage creator-quick-ui-forms.html
|
2011-12-14 15:07:05 +01:00
|
|
|
|
|
|
|
|
\title Creating Qt Quick Projects
|
|
|
|
|
|
|
|
|
|
\image qmldesigner-new-project.png "New File or Project dialog"
|
|
|
|
|
|
|
|
|
|
When you create a new Qt Quick project from scratch, you have the following
|
|
|
|
|
options:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2017-11-02 14:51:45 +01:00
|
|
|
\li \uicontrol {Qt Quick Application - Empty} creates a Qt Quick 2
|
|
|
|
|
application project that can contain both QML and C++ code. You can
|
|
|
|
|
build the application and deploy it to desktop, embedded, and mobile
|
|
|
|
|
target platforms.
|
|
|
|
|
|
|
|
|
|
\li \uicontrol {Qt Quick Application - Scroll} uses the
|
|
|
|
|
\l{http://doc.qt.io/qt-5/qml-qtquick-controls2-scrollview.html}
|
|
|
|
|
{ScrollView} type to implement a scrollable list view
|
|
|
|
|
(requires Qt 5.9 or later).
|
|
|
|
|
|
|
|
|
|
\li \uicontrol {Qt Quick Application - Stack} uses the
|
|
|
|
|
\l{http://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html}
|
|
|
|
|
{StackView} type to implement a set of pages with a stack-based
|
|
|
|
|
navigation model (requires Qt 5.7 or later).
|
|
|
|
|
|
|
|
|
|
\li \uicontrol {Qt Quick Application - Swipe} uses the
|
|
|
|
|
\l{http://doc.qt.io/qt-5/qml-qtquick-controls2-swipeview.html}
|
|
|
|
|
{SwipeWiew} type to implement a set of pages with a swipe-based
|
|
|
|
|
navigation model (requires Qt 5.7 or later).
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2015-07-09 15:54:45 +02:00
|
|
|
\li \uicontrol {Qt Canvas 3D Application} creates a Qt Quick application
|
|
|
|
|
that imports the Qt Canvas 3D module and, optionally, includes
|
|
|
|
|
\l{http://threejs.org}{three.js}.
|
|
|
|
|
|
2017-02-22 11:32:35 +01:00
|
|
|
\li \uicontrol {Qt Quick UI Prototype} (in the \uicontrol {Other Project}
|
2017-02-13 10:50:43 +01:00
|
|
|
category) creates a \l{Creating Qt Quick UI Projects}
|
|
|
|
|
{Qt Quick UI project} with a single QML file that
|
2017-02-03 16:57:55 +01:00
|
|
|
contains the main view. You can review Qt Quick 2 UI projects in the
|
|
|
|
|
\l{Previewing QML Files}{QML Scene preview tool}. You do not need to
|
|
|
|
|
build them, because they do not contain any C++ code.
|
2017-02-22 11:32:35 +01:00
|
|
|
Use this only if you are prototyping. You cannot create a full application
|
|
|
|
|
with this.
|
|
|
|
|
|
2017-02-13 10:50:43 +01:00
|
|
|
Qt Quick UI projects cannot be deployed to embedded or mobile
|
|
|
|
|
target platforms. For those platforms, create a Qt Quick application
|
|
|
|
|
instead.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2017-02-03 16:57:55 +01:00
|
|
|
\li \uicontrol {Qt Quick 2 Extension Plugin} (in the \uicontrol Library category)
|
2012-11-26 11:50:39 +01:00
|
|
|
create C++ plugins that make it possible to offer extensions that
|
2017-02-03 16:57:55 +01:00
|
|
|
can be loaded dynamically into Qt Quick 2 applications.
|
2011-12-14 15:07:05 +01:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
2017-02-03 16:57:55 +01:00
|
|
|
\note The SDK for a particular target platform might install additional
|
|
|
|
|
templates for that platform. For example, the QNX templates are installed
|
|
|
|
|
as part of the QNX SDK.
|
|
|
|
|
|
|
|
|
|
\QC creates the necessary boilerplate files. Some of the files are
|
|
|
|
|
specific to a particular target platform.
|
|
|
|
|
|
2017-11-02 14:51:45 +01:00
|
|
|
\section1 Creating Empty Qt Quick Applications
|
2015-07-03 11:03:04 +02:00
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
|
|
|
|
\li Select \uicontrol File > \uicontrol {New File or Project} >
|
2017-11-02 14:51:45 +01:00
|
|
|
\uicontrol Application > \uicontrol {Qt Quick Application - Empty} >
|
2017-02-03 16:57:55 +01:00
|
|
|
\uicontrol Choose.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2017-06-07 16:24:04 +02:00
|
|
|
\li In the \uicontrol Name field, enter a name for the application.
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol {Create in} field, enter the path for the project
|
|
|
|
|
files, and then select \uicontrol Next (or \uicontrol Continue on
|
|
|
|
|
\macos).
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol {Build system} field, select the build system to
|
|
|
|
|
use for building and running the project: \l qmake,
|
|
|
|
|
\l {Setting Up CMake}{CMake}, or \l {Setting Up Qbs}{Qbs}.
|
|
|
|
|
|
|
|
|
|
\li Select \uicontrol Next.
|
|
|
|
|
|
2017-02-03 16:57:55 +01:00
|
|
|
\li Select the Qt version to
|
2016-07-28 16:16:47 +02:00
|
|
|
develop with in the \uicontrol {Minimal required Qt version} field.
|
|
|
|
|
The Qt version determines the Qt Quick imports that are used in the
|
|
|
|
|
QML files.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2017-11-02 14:51:45 +01:00
|
|
|
\li Select the \uicontrol {Use Qt Virtual Keyboard} check box to add
|
|
|
|
|
support for \l{http://doc.qt.io/qt-5/qtvirtualkeyboard-index.html}
|
|
|
|
|
{Qt Virtual Keyboard} to the application.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2017-06-07 16:24:04 +02:00
|
|
|
\li Select \uicontrol Next.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
|
|
|
|
\li Select \l{glossary-buildandrun-kit}{kits} for running and building
|
|
|
|
|
your project, and then click \uicontrol Next.
|
|
|
|
|
|
|
|
|
|
\note Kits are listed if they have been specified in
|
|
|
|
|
\uicontrol Tools > \uicontrol Options > \uicontrol {Build & Run} >
|
|
|
|
|
\uicontrol Kits.
|
|
|
|
|
|
|
|
|
|
\li Review the project settings, and click \uicontrol Finish (on Windows
|
2016-08-03 16:46:29 +02:00
|
|
|
and Linux) or \uicontrol Done (on \macos) to create the project.
|
2011-12-14 15:07:05 +01:00
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
\endlist
|
|
|
|
|
|
2017-11-02 14:51:45 +01:00
|
|
|
\QC generates a QML file, \e main.qml, that you can modify in \QMLD.
|
|
|
|
|
|
|
|
|
|
\section1 Creating Qt Quick Controls 2 Applications
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
|
|
|
|
\li Select \uicontrol File > \uicontrol {New File or Project} >
|
|
|
|
|
\uicontrol Application > \uicontrol {Qt Quick Application - Scroll},
|
|
|
|
|
\uicontrol {Qt Quick Application - Stack}, or
|
|
|
|
|
\uicontrol {Qt Quick Application - Swipe} > \uicontrol Choose.
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol Name field, enter a name for the application.
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol {Create in} field, enter the path for the project
|
|
|
|
|
files, and then select \uicontrol Next (or \uicontrol Continue on
|
|
|
|
|
\macos).
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol {Build system} field, select the build system to
|
|
|
|
|
use for building and running the project: \l qmake,
|
|
|
|
|
\l {Setting Up CMake}{CMake}, or \l {Setting Up Qbs}{Qbs}.
|
|
|
|
|
|
|
|
|
|
\li In the \uicontrol {Qt Quick Controls 2 Style} field, select one of
|
|
|
|
|
the predefined \l{Styling Qt Quick Controls 2}{UI styles} to use,
|
|
|
|
|
and then select \uicontrol Next.
|
|
|
|
|
|
|
|
|
|
\li Select the \uicontrol {Use Qt Virtual Keyboard} check box to add
|
|
|
|
|
support for \l{http://doc.qt.io/qt-5/qtvirtualkeyboard-index.html}
|
|
|
|
|
{Qt Virtual Keyboard} to the application.
|
|
|
|
|
|
|
|
|
|
\li Select \l{glossary-buildandrun-kit}{kits} for the platforms that
|
|
|
|
|
you want to build the application for. To build applications for
|
|
|
|
|
mobile devices, select kits for Android ARM and iPhone OS, and
|
|
|
|
|
click \uicontrol{Next}.
|
|
|
|
|
|
|
|
|
|
\note Kits are listed if they have been specified in \uicontrol
|
|
|
|
|
Tools > \uicontrol Options > \uicontrol {Build & Run} >
|
|
|
|
|
\uicontrol Kits (on Windows and Linux) or in \uicontrol {Qt Creator}
|
|
|
|
|
> \uicontrol Preferences \uicontrol {Build & Run} > \uicontrol Kits
|
|
|
|
|
(on \macos).
|
|
|
|
|
|
|
|
|
|
\li Select \uicontrol Next.
|
|
|
|
|
|
|
|
|
|
\li Review the project settings, and click \uicontrol{Finish} (or
|
|
|
|
|
\uicontrol Done on \macos).
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
For the Scroll application, \QC creates a QML file, \e main.qml, that you
|
|
|
|
|
can modify in \QMLD.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
2017-11-02 14:51:45 +01:00
|
|
|
For the Stack and Swipe applications, \QC generates two UI files,
|
|
|
|
|
\e Page1Form.ui.qml and \e Page2Form.ui.qml, that you can modify in the
|
|
|
|
|
\QMLD \uicontrol {Form Editor} and a QML file, \e main.qml, that you can
|
|
|
|
|
modify in the \uicontrol {Text Editor} to add the application logic.
|
2015-07-03 11:03:04 +02:00
|
|
|
|
|
|
|
|
\section1 Creating Qt Quick UI Projects
|
2014-12-10 10:13:37 +01:00
|
|
|
|
2017-02-13 10:50:43 +01:00
|
|
|
Qt Quick UI projects are useful for testing or prototyping user interfaces,
|
|
|
|
|
or for setting up a separate project just for QML editing, for example. You
|
|
|
|
|
cannot use them for application development, because they do not contain:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
\li C++ code
|
|
|
|
|
\li Resource files (.qrc)
|
2017-08-17 17:02:56 +02:00
|
|
|
\li Code needed for deploying applications to \l{glossary-device}
|
|
|
|
|
{devices}
|
2017-02-13 10:50:43 +01:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To create a Qt Quick UI project:
|
|
|
|
|
|
2013-11-07 15:41:21 +01:00
|
|
|
\list 1
|
|
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
\li Select \uicontrol File > \uicontrol {New File or Project} >
|
2017-02-03 16:57:55 +01:00
|
|
|
\uicontrol {Other Project} > \uicontrol {Qt Quick UI} >
|
|
|
|
|
\uicontrol Choose.
|
2014-12-10 10:13:37 +01:00
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
\li In the \uicontrol {Minimal required Qt version} field, select the Qt
|
|
|
|
|
version to develop with. The Qt version determines the Qt Quick
|
|
|
|
|
imports that are used in the QML files.
|
2013-11-07 15:41:21 +01:00
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
You can add imports later to combine Qt Quick basic types with
|
|
|
|
|
Qt Quick Controls, Qt Quick Dialogs, and Qt Quick Layouts (available
|
|
|
|
|
since Qt 5.1).
|
2013-11-07 15:41:21 +01:00
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
\li Select the \uicontrol {With .ui.qml file} check box to create an UI
|
|
|
|
|
form.
|
2014-07-28 16:14:32 +02:00
|
|
|
|
2017-02-03 16:57:55 +01:00
|
|
|
\li Select \uicontrol Next (or \uicontrol Continue on \macos).
|
|
|
|
|
|
|
|
|
|
\li Review the project settings, and click \uicontrol Finish (on Windows
|
|
|
|
|
and Linux) or \uicontrol Done (on \macos) to create the project.
|
|
|
|
|
|
2013-11-07 15:41:21 +01:00
|
|
|
\endlist
|
2011-12-14 15:07:05 +01:00
|
|
|
|
|
|
|
|
\QC creates the following files:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li .qmlproject project file defines that all QML, JavaScript, and image
|
2011-12-14 15:07:05 +01:00
|
|
|
files in the project folder belong to the project. Therefore, you do
|
|
|
|
|
not need to individually list all the files in the project.
|
|
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\li .qml file defines an UI item, such as a component, screen, or the
|
2011-12-14 15:07:05 +01:00
|
|
|
whole application UI.
|
|
|
|
|
|
2015-07-03 11:03:04 +02:00
|
|
|
\li ui.qml file defines a form for the application UI. This file is
|
|
|
|
|
created if you selected the \uicontrol {With .ui.qml file} check
|
|
|
|
|
box.
|
2014-10-28 15:18:01 +01:00
|
|
|
|
2011-12-14 15:07:05 +01:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To use JavaScript and image files in the application, copy them to the
|
|
|
|
|
project folder.
|
|
|
|
|
|
|
|
|
|
*/
|