如何解决Qt Qml 垂直标签栏
我想以与 Qt Creater 在他们的应用程序中所做的类似的方式将 Vertical TabBar 添加到我的应用程序中(如图所示)。 我一直在寻找如何简单地使 TabBar 垂直,但没有找到正确的答案(认为垂直是很常见的)。
问题:如何制作垂直标签来浏览我拥有的不同 qml 文件?如果有更合适的选择,请提出。
解决方法
TabBar 只是使用一个普通的 ListView
来显示一堆 TabButtons
。您可以通过覆盖 contentItem
属性并使 ListView 垂直来自定义它,如下所示:
// VertTabBar.qml
TabBar {
id: control
contentItem: ListView {
model: control.contentModel
currentIndex: control.currentIndex
spacing: control.spacing
orientation: ListView.Vertical // <<-- VERTICAL
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.AutoFlickIfNeeded
snapMode: ListView.SnapToItem
highlightMoveDuration: 0
highlightRangeMode: ListView.ApplyRange
preferredHighlightBegin: 40
preferredHighlightEnd: height - 40
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。