diff options
author | Friedemann Kleint <[email protected]> | 2022-09-15 13:21:53 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2022-09-16 10:30:36 +0200 |
commit | cf32b66adbfb489cd6e5d5c0bf3f741b59ba204c (patch) | |
tree | 44be69c9487f5d4db1092d061a555bd6001c1ab4 /examples/quick/shared/TabSet.qml | |
parent | b20d6f6906f91f9df608d7800f4e27f7a7160abe (diff) |
Move examples around
Change the directory structure to closer match that of Qt.
Task-number: PYSIDE-841
Change-Id: I87aca346b6654aafe94dd1fb83c184c182ceb2e6
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Diffstat (limited to 'examples/quick/shared/TabSet.qml')
-rw-r--r-- | examples/quick/shared/TabSet.qml | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/examples/quick/shared/TabSet.qml b/examples/quick/shared/TabSet.qml new file mode 100644 index 000000000..633521af8 --- /dev/null +++ b/examples/quick/shared/TabSet.qml @@ -0,0 +1,69 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick 2.12 +import QtQuick.Window 2.1 + +Item { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setZOrders() + Component.onCompleted: setZOrders() + + function setZOrders() { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].z = (i == current ? 1 : 0) + stack.children[i].enabled = (i == current) + } + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + required property int index + width: tabWidget.width / stack.children.length + height: Math.max(Screen.pixelDensity * 7, label.implicitHeight * 1.2) + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "images/tab.png" + visible: tabWidget.current == parent.index + } + Text { + id: label + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[parent.index].title + elide: Text.ElideRight + font.bold: tabWidget.current == parent.index + } + TapHandler { + onTapped: tabWidget.current = parent.index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} |