本页内容

PageIndicator QML Type

表示当前处于活动状态的页面。更多...

Import Statement: import QtQuick.Controls
Inherits:

Control

属性

详细说明

PageIndicator 用于在包含多个页面的容器中指示当前活动页面。PageIndicator 由用于呈现页面的委托项组成。

显示当前页码位置的页码指示器

Column {
    StackLayout {
        id: stackLayout

        Page {
            // ...
        }
        Page {
            // ...
        }
        Page {
            // ...
        }
    }

    PageIndicator {
        currentIndex: stackLayout.currentIndex
        count: stackLayout.count
    }
}

另请参阅《 SwipeView》 、《自定义 PageIndicator》以及《指示器控件》。

属性文档

count : int

该属性存储页面数量。

currentIndex : int

该属性保存了当前页面的索引。

delegate : Component

该属性包含一个用于呈现页面的委托。

在每个委托的上下文中,可使用以下属性:

index: int该项的索引
pressed: bool项目是否被按下

PageIndicator 不会获取该委托的所有权。

interactive : bool

该属性用于指定控件是否具有交互性。交互式页面指示器会对点击操作做出响应,并自动相应地更改current index 。

SwipeView {
    id: view
    currentIndex: pageIndicator.currentIndex
    anchors.fill: parent

    Page {
        title: qsTr("Home")
    }
    Page {
        title: qsTr("Discover")
    }
    Page {
        title: qsTr("Activity")
    }
}

PageIndicator {
    id: pageIndicator
    interactive: true
    count: view.count
    currentIndex: view.currentIndex

    anchors.bottom: parent.bottom
    anchors.horizontalCenter: parent.horizontalCenter
}

注意:页面指示器 通常尺寸较小(以避免分散用户对用户界面实际内容的注意力)。它们可能难以点击,且用户可能难以将其识别为可交互元素。基于这些原因,最好将它们用作主要导航方式(如SwipeView )的补充,而非替代。

默认值为false 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.