diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2023-04-27 13:20:28 +0800 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2023-05-03 10:08:51 +0800 |
commit | 7e745bbba235c41107292da06dc63beabf3c913c (patch) | |
tree | cf8089bb3c0892d05af26fa8827cebd636a67352 | |
parent | 4ab11d03ac2aecec3d4d304e566c9bb161e22090 (diff) | |
download | qtdeclarative-7e745bbba235c41107292da06dc63beabf3c913c.tar.gz |
Doc: explain how to handle currentIndex changes in TabBar and SwipeView
Add a snippet and link to property change signal handlers to explain
the concept, since that page is hard to find unless you know where to
look.
Pick-to: 6.5
Change-Id: Id4019076d55199a9cafe4acdced1a7efc64bb3f2
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
-rw-r--r-- | src/quickcontrols/doc/snippets/qtquickcontrols-container-oncurrentindexchanged.qml | 13 | ||||
-rw-r--r-- | src/quickcontrols/doc/src/includes/container-currentindex.qdocinc | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/quickcontrols/doc/snippets/qtquickcontrols-container-oncurrentindexchanged.qml b/src/quickcontrols/doc/snippets/qtquickcontrols-container-oncurrentindexchanged.qml new file mode 100644 index 0000000000..e018486fef --- /dev/null +++ b/src/quickcontrols/doc/snippets/qtquickcontrols-container-oncurrentindexchanged.qml @@ -0,0 +1,13 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +import QtQuick.Controls + +Container { + //! [1] + onCurrentIndexChanged: { + print("currentIndex changed to", currentIndex) + // ... + } + //! [1] +} diff --git a/src/quickcontrols/doc/src/includes/container-currentindex.qdocinc b/src/quickcontrols/doc/src/includes/container-currentindex.qdocinc index 9fcf43e168..776e39dcfc 100644 --- a/src/quickcontrols/doc/src/includes/container-currentindex.qdocinc +++ b/src/quickcontrols/doc/src/includes/container-currentindex.qdocinc @@ -6,4 +6,10 @@ of each control. To do this without breaking bindings, avoid setting \c currentIndex directly, and instead use \l {Container::}{setCurrentIndex()}, for example. See \l {Managing the Current Index} for more information. + +To perform an action when \c currentIndex changes, use the +\c onCurrentIndexChanged +\l {Property Change Signal Handlers}{property change signal handler}: + +\snippet qtquickcontrols-container-oncurrentindexchanged.qml 1 //! [file] |