diff options
author | Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> | 2016-11-18 17:35:29 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2016-11-30 14:28:25 +0000 |
commit | 63c34dc6c1c6f24f8e83f295adc70fdcc392f8c5 (patch) | |
tree | 8081b7de90b5f2deab0fe74af7991229070dbc6c /examples/quick/demos/stocqt/stocqt.qml | |
parent | 005857c492ff2a907987e5aed4c61163a6f3fc44 (diff) |
StocQt example: Use QtQuick.Layouts instead of anchors
- Move the StockListView delegate and the top banner to
separate files.
- Use QtQuick.Layouts in place of anchors for most parts,
improving code readability and app scalability.
Change-Id: Ie8f13ef261bb343f15e9484bd15f8b94101daeb5
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples/quick/demos/stocqt/stocqt.qml')
-rw-r--r-- | examples/quick/demos/stocqt/stocqt.qml | 115 |
1 files changed, 38 insertions, 77 deletions
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml index 6b1da1713a..a13e63fd50 100644 --- a/examples/quick/demos/stocqt/stocqt.qml +++ b/examples/quick/demos/stocqt/stocqt.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtQml.Models 2.1 +import QtQuick.Layouts 1.1 import "./content" Rectangle { @@ -49,90 +50,50 @@ Rectangle { property alias currentIndex: root.currentIndex - Rectangle { - id: banner - height: 80 - anchors.top: parent.top - width: parent.width - color: "#000000" + ColumnLayout { + anchors.fill: parent - Image { - id: arrow - source: "./content/images/icon-left-arrow.png" - anchors.left: banner.left - anchors.leftMargin: 20 - anchors.verticalCenter: banner.verticalCenter - visible: root.currentIndex == 1 ? true : false - - MouseArea { - anchors.fill: parent - onClicked: root.currentIndex = 0; - } - } - - Item { - id: textItem - width: stocText.width + qtText.width - height: stocText.height + qtText.height - anchors.horizontalCenter: banner.horizontalCenter - anchors.verticalCenter: banner.verticalCenter - - Text { - id: stocText - anchors.verticalCenter: textItem.verticalCenter - color: "#ffffff" - font.family: "Abel" - font.pointSize: 40 - text: "Stoc" - } - Text { - id: qtText - anchors.verticalCenter: textItem.verticalCenter - anchors.left: stocText.right - color: "#5caa15" - font.family: "Abel" - font.pointSize: 40 - text: "Qt" - } + Banner { + id: banner + Layout.fillWidth: true } - } - ListView { - id: root - width: parent.width - anchors.top: banner.bottom - anchors.bottom: parent.bottom - snapMode: ListView.SnapOneItem - highlightRangeMode: ListView.StrictlyEnforceRange - highlightMoveDuration: 250 - focus: false - orientation: ListView.Horizontal - boundsBehavior: Flickable.StopAtBounds + ListView { + id: root + Layout.fillHeight: true + Layout.fillWidth: true + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 250 + focus: false + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds - StockModel { - id: stock - stockId: listView.currentStockId - stockName: listView.currentStockName - onStockIdChanged: stock.updateStock(); - onDataReady: { - root.currentIndex = 1 - stockView.update() + StockModel { + id: stock + stockId: listView.currentStockId + stockName: listView.currentStockName + onStockIdChanged: stock.updateStock(); + onDataReady: { + root.currentIndex = 1 + stockView.update() + } } - } - model: ObjectModel { - StockListView { - id: listView - width: root.width - height: root.height - } + model: ObjectModel { + StockListView { + id: listView + width: root.width + height: root.height + } - StockView { - id: stockView - width: root.width - height: root.height - stocklist: listView - stock: stock + StockView { + id: stockView + width: root.width + height: root.height + stocklist: listView + stock: stock + } } } } |