summaryrefslogtreecommitdiffstats
path: root/examples/corelib/bindableproperties/shared
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-11-25 11:08:01 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2021-12-02 12:53:34 +0100
commitcee89e70a6011c3fcae29ad95d5fec4b2026d055 (patch)
tree1ac0d600fb97cc7b1951319cac8d306168278445 /examples/corelib/bindableproperties/shared
parent75eb08711ef7a51305b4daad411548a2b6b4f8c6 (diff)
Add example showing the benefits of using bindable properties
Added two examples for modeling a subscription service: signal/slot connection-based and bindable property-based. The examples are based on the example from Fabian's Qt WS talk about the bindable properties. Pick-to: 6.2 Task-number: QTBUG-97655 Change-Id: I0345913b8b6e5c40b8477e128d36483598bdfcaa Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/corelib/bindableproperties/shared')
-rw-r--r--examples/corelib/bindableproperties/shared/countries.qrc7
-rw-r--r--examples/corelib/bindableproperties/shared/finland.pngbin0 -> 1062 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/germany.pngbin0 -> 483 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/norway.pngbin0 -> 5190 bytes
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.cpp63
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.h76
-rw-r--r--examples/corelib/bindableproperties/shared/subscriptionwindow.ui280
7 files changed, 426 insertions, 0 deletions
diff --git a/examples/corelib/bindableproperties/shared/countries.qrc b/examples/corelib/bindableproperties/shared/countries.qrc
new file mode 100644
index 0000000000..cdf6312ebb
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/countries.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>germany.png</file>
+ <file>norway.png</file>
+ <file>finland.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/corelib/bindableproperties/shared/finland.png b/examples/corelib/bindableproperties/shared/finland.png
new file mode 100644
index 0000000000..92653289c1
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/finland.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/germany.png b/examples/corelib/bindableproperties/shared/germany.png
new file mode 100644
index 0000000000..efc389f52a
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/germany.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/norway.png b/examples/corelib/bindableproperties/shared/norway.png
new file mode 100644
index 0000000000..daee6c3c15
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/norway.png
Binary files differ
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp
new file mode 100644
index 0000000000..03269dfa0c
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#include "subscriptionwindow.h"
+#include "ui_subscriptionwindow.h"
+
+SubscriptionWindow::SubscriptionWindow(QWidget *parent)
+ : QWidget(parent), ui(new Ui::SubscriptionWindow)
+{
+ ui->setupUi(this);
+}
+
+SubscriptionWindow::~SubscriptionWindow()
+{
+ delete ui;
+}
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.h b/examples/corelib/bindableproperties/shared/subscriptionwindow.h
new file mode 100644
index 0000000000..9bc3acd91a
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $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$
+**
+****************************************************************************/
+
+#ifndef SUBSCRIPTIONWINDOW_H
+#define SUBSCRIPTIONWINDOW_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class SubscriptionWindow;
+}
+QT_END_NAMESPACE
+
+class User;
+
+class SubscriptionWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit SubscriptionWindow(QWidget *parent = nullptr);
+ ~SubscriptionWindow();
+
+private:
+ Ui::SubscriptionWindow *ui;
+};
+
+#endif // SUBSCRIPTIONWINDOW_H
diff --git a/examples/corelib/bindableproperties/shared/subscriptionwindow.ui b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui
new file mode 100644
index 0000000000..7bc2931373
--- /dev/null
+++ b/examples/corelib/bindableproperties/shared/subscriptionwindow.ui
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SubscriptionWindow</class>
+ <widget class="QWidget" name="SubscriptionWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>639</width>
+ <height>269</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Subscription</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0,0,0">
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnGermany">
+ <property name="toolTip">
+ <string>Germany</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/germany.png</normaloff>:/germany.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnNorway">
+ <property name="toolTip">
+ <string>Norway</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/norway.png</normaloff>:/norway.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnFinland">
+ <property name="toolTip">
+ <string>Finland</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/finland.png</normaloff>:/finland.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="ageLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Age</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="ageSpinBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="intervalLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Interval</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnMonthly">
+ <property name="text">
+ <string>Monthly</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnQuarterly">
+ <property name="text">
+ <string>Quarterly</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="btnYearly">
+ <property name="text">
+ <string>Yearly</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="priceLabel">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Price/month</string>
+ </property>
+ <property name="margin">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="priceDisplay">
+ <property name="text">
+ <string>0.0</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>