diff options
| -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] |
