diff --git a/src/Qt5/imports/FluentUI/Controls/FluScrollablePage.qml b/src/Qt5/imports/FluentUI/Controls/FluScrollablePage.qml index 5e1eb09f..573df65d 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluScrollablePage.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluScrollablePage.qml @@ -5,8 +5,11 @@ import QtQuick.Controls 2.15 import FluentUI 1.0 FluPage { + property bool autoResetScroll: false default property alias content: container.data + Flickable{ + id: flickable clip: true anchors.fill: parent ScrollBar.vertical: FluScrollBar {} @@ -17,4 +20,14 @@ FluPage { width: parent.width } } + + function resetScroll() { + flickable.contentY = 0; + } + + StackView.onActivated: { + if (autoResetScroll) { + resetScroll(); // Call this function to reset the scroll position to the top + } + } } diff --git a/src/Qt6/imports/FluentUI/Controls/FluScrollablePage.qml b/src/Qt6/imports/FluentUI/Controls/FluScrollablePage.qml index ca710e5f..51e7ade6 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluScrollablePage.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluScrollablePage.qml @@ -5,8 +5,11 @@ import QtQuick.Controls import FluentUI FluPage { + property bool autoResetScroll: false default property alias content: container.data + Flickable{ + id: flickable clip: true anchors.fill: parent ScrollBar.vertical: FluScrollBar {} @@ -17,4 +20,14 @@ FluPage { width: parent.width } } + + function resetScroll() { + flickable.contentY = 0; + } + + StackView.onActivated: { + if (autoResetScroll) { + resetScroll(); // Call this function to reset the scroll position to the top + } + } }