C
SwipeView QML Type
允许用户通过侧向滑动来浏览页面。更多...
| Import Statement: | import QtQuick.Controls |
| Since: | Qt Quick Ultralite 1.0 |
| Inherits: |
属性
- count : int
- currentIndex : int
- currentItem : Item
- interactive : bool
- orientation : Qt::Orientation
方法
- void decrementCurrentIndex()
- void incrementCurrentIndex()
- void setCurrentIndex(int index)
详细说明
SwipeView 提供了一种基于滑动的导航模式。
SwipeView 中包含一组页面。每次仅显示一个页面。用户可以通过横向滑动在页面之间进行导航。请注意,SwipeView 本身完全是非可视化的。
SwipeView{ id: theSwipe width: 150; height: 150 clip: true Rectangle { color: "red" } Rectangle { color: "yellow" } Rectangle { color: "lightGreen" } }
如上所示,SwipeView 包含一组静态页面,这些页面作为视图的子元素内联定义。
通常不建议向 SwipeView 中添加过多的页面。但是,当页面数量增加,或者单个页面相对较复杂时,可能需要通过卸载用户当前无法直接访问的页面来释放资源。另请参阅《Qt Quick Ultralite 性能指南》中的“动态加载组件”一节。
注意:SwipeView 会接管添加到视图中的项的几何管理。不支持在项上使用锚点,且任何width 或height 的赋值都会被视图覆盖。请注意,这仅适用于项的根节点。为其子项指定宽度和高度,或使用锚点,均可按预期工作。
注意:SwipeView 基于QtQuick.Templates::SwipeView,这要求contentItem 必须是Flickable 。不支持使用任何其他contentItem。
另请参阅 “控件样式设置”。
属性文档
count : int [read-only]
该属性保存了SwipeView 中的页面数量。
另请参阅 currentIndex 。
currentIndex : int
该属性保存当前可见项的索引。可用于自动滚动到特定页面。
另请参阅 currentItem 。
currentItem : Item [read-only]
该属性保存当前可见的项目。
另请参阅 currentIndex 。
interactive : bool
该属性描述了用户是否可以与SwipeView 进行交互。用户无法滑动非交互式视图。
默认值为true 。
orientation : Qt::Orientation
该属性用于存储方向。
方法文档
void decrementCurrentIndex()
这会将当前页面切换为索引较小的那个页面。
另请参阅 currentIndex 、incrementCurrentIndex 以及setCurrentIndex 。
void incrementCurrentIndex()
这会将当前页面切换为索引较高的页面。
另请参阅 currentIndex 、decrementCurrentIndex 以及setCurrentIndex 。
void setCurrentIndex(int index)
这将当前页面切换为位于index 的页面。
另请参阅 currentIndex 、decrementCurrentIndex 以及incrementCurrentIndex 。
在某些 Qt 许可证下可用。
了解更多。