diff options
Diffstat (limited to 'src/quickcontrols/doc/snippets/qtquickcontrols-scrollbar-custom.qml')
-rw-r--r-- | src/quickcontrols/doc/snippets/qtquickcontrols-scrollbar-custom.qml | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/quickcontrols/doc/snippets/qtquickcontrols-scrollbar-custom.qml b/src/quickcontrols/doc/snippets/qtquickcontrols-scrollbar-custom.qml new file mode 100644 index 0000000000..5ad266dc93 --- /dev/null +++ b/src/quickcontrols/doc/snippets/qtquickcontrols-scrollbar-custom.qml @@ -0,0 +1,29 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [file] +import QtQuick +import QtQuick.Controls + +ScrollBar { + id: control + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + + contentItem: Rectangle { + implicitWidth: 6 + implicitHeight: 100 + radius: width / 2 + color: control.pressed ? "#81e889" : "#c2f4c6" + // Hide the ScrollBar when it's not needed. + opacity: control.policy === ScrollBar.AlwaysOn || (control.active && control.size < 1.0) ? 0.75 : 0 + + // Animate the changes in opacity (default duration is 250 ms). + Behavior on opacity { + NumberAnimation {} + } + } +} +//! [file] |