aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples
diff options
context:
space:
mode:
authorLeena Miettinen <riitta-leena.miettinen@qt.io>2016-12-07 14:58:32 +0100
committerLeena Miettinen <riitta-leena.miettinen@qt.io>2016-12-16 16:08:56 +0000
commit6175b2f404bcd187bfc10312cab1d670917be098 (patch)
tree52afa4b6fb7feab70e80dc0be4b7e59e618d061f /doc/examples
parent48adeb1a82b2e1db4dad50da0460c4765a4d89bb (diff)
Doc: Update accelbubble example to use Qt Quick Controls 2
Change-Id: I946e9cb31517f602ce07fe1967a87bfdf9bd79b0 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/accelbubble/Bubble.qml8
-rw-r--r--doc/examples/accelbubble/Page1.qml55
-rw-r--r--doc/examples/accelbubble/Page1Form.ui.qml (renamed from doc/examples/accelbubble/MainForm.ui.qml)27
-rw-r--r--doc/examples/accelbubble/accelbubble.pro20
-rw-r--r--doc/examples/accelbubble/main.cpp5
-rw-r--r--doc/examples/accelbubble/main.qml67
-rw-r--r--doc/examples/accelbubble/qml.qrc4
-rw-r--r--doc/examples/accelbubble/qtquickcontrols2.conf15
8 files changed, 138 insertions, 63 deletions
diff --git a/doc/examples/accelbubble/Bubble.qml b/doc/examples/accelbubble/Bubble.qml
index 9a93069aeb..bb21875951 100644
--- a/doc/examples/accelbubble/Bubble.qml
+++ b/doc/examples/accelbubble/Bubble.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2016 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 Qt Creator
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,9 +48,9 @@
**
****************************************************************************/
-import QtQuick 2.5
-import QtQuick.Controls 1.4
-import QtQuick.Layouts 1.2
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
Image {
source: "Bluebubble.svg"
diff --git a/doc/examples/accelbubble/Page1.qml b/doc/examples/accelbubble/Page1.qml
new file mode 100644
index 0000000000..0619779873
--- /dev/null
+++ b/doc/examples/accelbubble/Page1.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator
+**
+** $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$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+
+Page1Form {
+
+}
diff --git a/doc/examples/accelbubble/MainForm.ui.qml b/doc/examples/accelbubble/Page1Form.ui.qml
index 3e637dbb7d..d336fa3b7a 100644
--- a/doc/examples/accelbubble/MainForm.ui.qml
+++ b/doc/examples/accelbubble/Page1Form.ui.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2016 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 Qt Creator
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,31 +48,20 @@
**
****************************************************************************/
-import QtQuick 2.5
-import QtQuick.Controls 1.4
-import QtQuick.Layouts 1.2
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
Item {
- id: id
- width: 640
- height: 480
- property alias bubble: bubble
property alias mainWindow: mainWindow
-
+ property alias bubble: bubble
Rectangle {
id: mainWindow
color: "#ffffff"
- anchors.rightMargin: 0
- anchors.bottomMargin: 0
- anchors.leftMargin: 0
- anchors.topMargin: 0
anchors.fill: parent
- }
- Bubble {
- id: bubble
- x: 10
- y: 18
+ Bubble {
+ id: bubble
+ }
}
-
}
diff --git a/doc/examples/accelbubble/accelbubble.pro b/doc/examples/accelbubble/accelbubble.pro
index 5f1734b9ee..dca3207dce 100644
--- a/doc/examples/accelbubble/accelbubble.pro
+++ b/doc/examples/accelbubble/accelbubble.pro
@@ -1,5 +1,3 @@
-TEMPLATE = app
-
QT += qml quick sensors svg xml
CONFIG += c++11
@@ -11,5 +9,21 @@ RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# 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.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
# Default rules for deployment.
-include(deployment.pri)
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
diff --git a/doc/examples/accelbubble/main.cpp b/doc/examples/accelbubble/main.cpp
index 618e0f3da8..6ff25a462c 100644
--- a/doc/examples/accelbubble/main.cpp
+++ b/doc/examples/accelbubble/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 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 Qt Creator
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -53,10 +53,11 @@
int main(int argc, char *argv[])
{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ engine.load(QUrl(QLatin1String("qrc:/main.qml")));
return app.exec();
}
diff --git a/doc/examples/accelbubble/main.qml b/doc/examples/accelbubble/main.qml
index 25be59c135..ddd617af69 100644
--- a/doc/examples/accelbubble/main.qml
+++ b/doc/examples/accelbubble/main.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2016 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 Qt Creator
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
@@ -48,19 +48,18 @@
**
****************************************************************************/
-import QtQuick 2.5
-import QtQuick.Controls 1.4
-import QtQuick.Dialogs 1.2
-import QtSensors 5.5
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
+import QtSensors 5.7
ApplicationWindow {
- id: mainWindow
visible: true
width: 640
height: 480
title: qsTr("Accelerate Bubble")
- MainForm {
+ Page1 {
anchors.fill: parent
bubble {
id: bubble
@@ -83,41 +82,41 @@ ApplicationWindow {
}
}
}
-}
+ }
-Accelerometer {
- id: accel
- dataRate: 100
- active: true
+ Accelerometer {
+ id: accel
+ dataRate: 100
+ active: true
- onReadingChanged: {
- var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
- var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
+ onReadingChanged: {
+ var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
+ var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * 0.1)
- if (isNaN(newX) || isNaN(newY))
- return;
+ if (isNaN(newX) || isNaN(newY))
+ return;
- if (newX < 0)
- newX = 0
+ if (newX < 0)
+ newX = 0
- if (newX > mainWindow.width - bubble.width)
- newX = mainWindow.width - bubble.width
+ if (newX > mainWindow.width - bubble.width)
+ newX = mainWindow.width - bubble.width
- if (newY < 18)
- newY = 18
+ if (newY < 18)
+ newY = 18
- if (newY > mainWindow.height - bubble.height)
- newY = mainWindow.height - bubble.height
+ if (newY > mainWindow.height - bubble.height)
+ newY = mainWindow.height - bubble.height
- bubble.x = newX
- bubble.y = newY
+ bubble.x = newX
+ bubble.y = newY
+ }
}
- }
- function calcPitch(x, y, z) {
- return -(Math.atan(y / Math.sqrt(x * x + z * z)) * 57.2957795);
- }
- function calcRoll(x, y, z) {
- return -(Math.atan(x / Math.sqrt(y * y + z * z)) * 57.2957795);
- }
+ function calcPitch(x, y, z) {
+ return -(Math.atan(y / Math.sqrt(x * x + z * z)) * 57.2957795);
+ }
+ function calcRoll(x, y, z) {
+ return -(Math.atan(x / Math.sqrt(y * y + z * z)) * 57.2957795);
+ }
}
diff --git a/doc/examples/accelbubble/qml.qrc b/doc/examples/accelbubble/qml.qrc
index 21530e7039..1825fab490 100644
--- a/doc/examples/accelbubble/qml.qrc
+++ b/doc/examples/accelbubble/qml.qrc
@@ -1,7 +1,9 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
- <file>MainForm.ui.qml</file>
+ <file>Page1.qml</file>
+ <file>Page1Form.ui.qml</file>
+ <file>qtquickcontrols2.conf</file>
<file>Bubble.qml</file>
<file>Bluebubble.svg</file>
</qresource>
diff --git a/doc/examples/accelbubble/qtquickcontrols2.conf b/doc/examples/accelbubble/qtquickcontrols2.conf
new file mode 100644
index 0000000000..1764b16fb4
--- /dev/null
+++ b/doc/examples/accelbubble/qtquickcontrols2.conf
@@ -0,0 +1,15 @@
+; This file can be edited to change the style of the application
+; See Styling Qt Quick Controls 2 in the documentation for details:
+; http://doc.qt.io/qt-5/qtquickcontrols2-styles.html
+
+[Controls]
+Style=Default
+
+[Universal]
+Theme=Light
+;Accent=Steel
+
+[Material]
+Theme=Light
+;Accent=BlueGrey
+;Primary=BlueGray