Doc: Update Qt Quick app tutorial
Task-number: QTCREATORBUG-23364 Change-Id: Ib5fc260219a2e29c0762456e8b3c8d7e82954043 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator
|
** This file is part of Qt Creator
|
||||||
@@ -47,13 +47,20 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import QtQuick 2.9
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.5
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: page
|
id: page
|
||||||
width: 600
|
width: 600
|
||||||
height: 400
|
height: 400
|
||||||
|
property alias mouseArea2: mouseArea2
|
||||||
|
property alias mouseArea1: mouseArea1
|
||||||
|
property alias mouseArea: mouseArea
|
||||||
|
property alias icon: icon
|
||||||
|
property alias bottomLeftRect: bottomLeftRect
|
||||||
|
property alias middleRightRect: middleRightRect
|
||||||
|
property alias topLeftRect: topLeftRect
|
||||||
|
|
||||||
header: Label {
|
header: Label {
|
||||||
text: qsTr("Page 1")
|
text: qsTr("Page 1")
|
||||||
@@ -61,20 +68,12 @@ Page {
|
|||||||
padding: 10
|
padding: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
property alias icon: icon
|
|
||||||
property alias topLeftRect: topLeftRect
|
|
||||||
property alias bottomLeftRect: bottomLeftRect
|
|
||||||
property alias middleRightRect: middleRightRect
|
|
||||||
|
|
||||||
property alias mouseArea2: mouseArea2
|
|
||||||
property alias mouseArea1: mouseArea1
|
|
||||||
property alias mouseArea: mouseArea
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: icon
|
id: icon
|
||||||
x: 10
|
x: 10
|
||||||
y: 20
|
y: 20
|
||||||
source: "qt-logo.png"
|
source: "qt-logo.png"
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -82,11 +81,11 @@ Page {
|
|||||||
width: 55
|
width: 55
|
||||||
height: 41
|
height: 41
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
|
border.color: "#808080"
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
border.color: "#808080"
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
@@ -99,10 +98,10 @@ Page {
|
|||||||
width: 55
|
width: 55
|
||||||
height: 41
|
height: 41
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
|
border.color: "#808080"
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 10
|
anchors.rightMargin: 10
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
border.color: "#808080"
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea1
|
id: mouseArea1
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -114,14 +113,26 @@ Page {
|
|||||||
width: 55
|
width: 55
|
||||||
height: 41
|
height: 41
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
|
border.color: "#808080"
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: 20
|
anchors.bottomMargin: 20
|
||||||
border.color: "#808080"
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 10
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea2
|
id: mouseArea2
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
anchors.left: parent.left
|
}
|
||||||
anchors.leftMargin: 10
|
|
||||||
|
NumberAnimation {
|
||||||
|
id: numberAnimation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*##^##
|
||||||
|
Designer {
|
||||||
|
D{i:0;formeditorZoom:0.75}D{i:4;anchors_height:100;anchors_width:100}D{i:6;anchors_height:100;anchors_width:100}
|
||||||
|
D{i:8;anchors_height:100;anchors_width:100}
|
||||||
|
}
|
||||||
|
##^##*/
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator
|
** This file is part of Qt Creator
|
||||||
@@ -47,8 +47,8 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
import QtQuick 2.9
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.5
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
width: 600
|
width: 600
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator
|
** This file is part of Qt Creator
|
||||||
@@ -47,20 +47,28 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
if (qEnvironmentVariableIsEmpty("QTGLESSTREAM_DISPLAY")) {
|
||||||
|
qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", QByteArray("213"));
|
||||||
|
qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", QByteArray("120"));
|
||||||
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
}
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
const QUrl url(QStringLiteral("qrc:/main.qml"));
|
||||||
if (engine.rootObjects().isEmpty())
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
return -1;
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||||
|
if (!obj && url == objUrl)
|
||||||
|
QCoreApplication::exit(-1);
|
||||||
|
}, Qt::QueuedConnection);
|
||||||
|
engine.load(url);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of Qt Creator
|
** This file is part of Qt Creator
|
||||||
@@ -47,9 +47,8 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
import QtQuick 2.12
|
||||||
import QtQuick 2.9
|
import QtQuick.Controls 2.5
|
||||||
import QtQuick.Controls 2.2
|
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
visible: true
|
visible: true
|
||||||
@@ -64,7 +63,6 @@ ApplicationWindow {
|
|||||||
|
|
||||||
Page1Form {
|
Page1Form {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
mouseArea {
|
mouseArea {
|
||||||
onClicked: stateGroup.state = ' '
|
onClicked: stateGroup.state = ' '
|
||||||
}
|
}
|
||||||
@@ -102,6 +100,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
transitions: [
|
transitions: [
|
||||||
Transition {
|
Transition {
|
||||||
from: "*"; to: "State1"
|
from: "*"; to: "State1"
|
||||||
|
@@ -1,18 +1,20 @@
|
|||||||
QT += quick
|
QT += quick
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
# The following define makes your compiler emit warnings if you use
|
||||||
# any feature of Qt which as been marked deprecated (the exact warnings
|
# any Qt feature that has been marked deprecated (the exact warnings
|
||||||
# depend on your compiler). Please consult the documentation of the
|
# depend on your compiler). Refer to the documentation for the
|
||||||
# deprecated API in order to know how to port your code away from it.
|
# deprecated API to know how to port your code away from it.
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
# You can also make your code fail to compile if you use deprecated APIs.
|
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += main.cpp
|
SOURCES += \
|
||||||
|
main.cpp
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc
|
||||||
|
|
||||||
@@ -26,3 +28,5 @@ QML_DESIGNER_IMPORT_PATH =
|
|||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
DISTFILES +=
|
||||||
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2019 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the Qt Creator documentation.
|
** This file is part of the Qt Creator documentation.
|
||||||
@@ -72,14 +72,17 @@
|
|||||||
|
|
||||||
\image qmldesigner-tutorial-design-mode.png "Transitions project in Design Mode"
|
\image qmldesigner-tutorial-design-mode.png "Transitions project in Design Mode"
|
||||||
|
|
||||||
|
\note If a view is hidden, you can show it by selecting
|
||||||
|
\uicontrol Window > \uicontrol Views.
|
||||||
|
|
||||||
\li In the \uicontrol Navigator, select \uicontrol Label and press
|
\li In the \uicontrol Navigator, select \uicontrol Label and press
|
||||||
\key Delete to delete it.
|
\key Delete to delete it.
|
||||||
|
|
||||||
\li Select \uicontrol Page in the navigator, and enter \e page in the
|
\li Select \uicontrol Page in \uicontrol Navigator, and enter \e page in
|
||||||
\uicontrol Id field.
|
the \uicontrol Id field in the \uicontrol Properties view.
|
||||||
|
|
||||||
\li In \uicontrol Library > \uicontrol Assets, select qt-logo.png and
|
\li In \uicontrol Library > \uicontrol Assets, select qt-logo.png and
|
||||||
drag and drop it to the \e page in the navigator.
|
drag and drop it to the \e page in \uicontrol Navigator.
|
||||||
|
|
||||||
\image qmldesigner-tutorial-user-icon.png "Image properties"
|
\image qmldesigner-tutorial-user-icon.png "Image properties"
|
||||||
|
|
||||||
@@ -92,12 +95,14 @@
|
|||||||
|
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
\li Right-click the resource file, qml.qrc, in the \uicontrol Projects
|
\li In the \uicontrol Projects view, right-click the resource file,
|
||||||
view, and select \uicontrol {Add Existing File} to add qt-logo.png
|
qml.qrc, and select \uicontrol {Add Existing File} to add
|
||||||
to the resource file for deployment.
|
qt-logo.png to the resource file for deployment.
|
||||||
|
|
||||||
\li Drag and drop a \uicontrol Rectangle to \e page in the navigator and
|
\li In \uicontrol Library > \uicontrol {QML Types} >
|
||||||
edit its properties.
|
\uicontrol {Qt Quick - Basic}, select \uicontrol Rectangle,
|
||||||
|
drag and drop it to \e page in \uicontrol Navigator, and
|
||||||
|
edit its properties in the \uicontrol Properties view.
|
||||||
|
|
||||||
\image qmldesigner-tutorial-topleftrect.png "Rectangle properties"
|
\image qmldesigner-tutorial-topleftrect.png "Rectangle properties"
|
||||||
|
|
||||||
@@ -131,7 +136,7 @@
|
|||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
\li Drag and drop a \uicontrol {Mouse Area} type from the
|
\li Drag and drop a \uicontrol {Mouse Area} type from the
|
||||||
\uicontrol Library to \e topLeftRect in the navigator.
|
\uicontrol Library to \e topLeftRect in \uicontrol Navigator.
|
||||||
|
|
||||||
\li Click \uicontrol {Layout}, and then click the
|
\li Click \uicontrol {Layout}, and then click the
|
||||||
\inlineimage anchor-fill.png
|
\inlineimage anchor-fill.png
|
||||||
@@ -139,9 +144,9 @@
|
|||||||
rectangle.
|
rectangle.
|
||||||
|
|
||||||
\li In the \uicontrol Navigator, copy topLeftRect (by pressing
|
\li In the \uicontrol Navigator, copy topLeftRect (by pressing
|
||||||
\key {Ctrl+C}) and paste it to the \e page in the navigator twice
|
\key {Ctrl+C}) and paste it to \e page in \uicontrol Navigator
|
||||||
(by pressing \key {Ctrl+V}). \QC renames the new instances of the
|
twice (by pressing \key {Ctrl+V}). \QC renames the new instances
|
||||||
type topLeftRect1 and topLeftRect2.
|
of the type topLeftRect1 and topLeftRect2.
|
||||||
|
|
||||||
\li Select topLeftRect1 and edit its properties:
|
\li Select topLeftRect1 and edit its properties:
|
||||||
|
|
||||||
@@ -213,16 +218,11 @@
|
|||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
|
|
||||||
\li Specify the window size and background color as properties of
|
|
||||||
the ApplicationWindow type:
|
|
||||||
|
|
||||||
\quotefromfile transitions/main.qml
|
|
||||||
\skipto ApplicationWindow
|
|
||||||
\printuntil title
|
|
||||||
|
|
||||||
\li Specify an id for the Page1 type to be able to use the properties
|
\li Specify an id for the Page1 type to be able to use the properties
|
||||||
that you exported in \e Page1Form.ui.qml:
|
that you exported in \e Page1Form.ui.qml:
|
||||||
|
|
||||||
|
\quotefromfile transitions/main.qml
|
||||||
|
\skipto ApplicationWindow
|
||||||
\printuntil page
|
\printuntil page
|
||||||
|
|
||||||
\li Add a pointer to the clicked expressions in \uicontrol mouseArea:
|
\li Add a pointer to the clicked expressions in \uicontrol mouseArea:
|
||||||
|