自定义qml滑动条Slider
2017-06-29 15:15
786 查看
自定义qml滑动条Slider
作者 qq 843230304效果图:红色箭头所指的部分(如图所示,控制页面的滑动)
控制Flickable及其子类的页面滑动显示,比如ListView\GridView
用法
ListView{//GridView id:myList …… } MediaFileSlider{ id: wifiSlider visible: true anchors.right: parent.right list: myList//指定某个list width:25 height:540 }
源码
import QtQuick 2.0 Item{ id: root property variant list:undefined Rectangle { id: sliderbar width: parent.width height: parent.height color: "#19ffffff" radius: 1 anchors.right: parent.right MouseArea{ id:mouseScrollbar anchors.fill: parent onClicked: { var pt = mouseY < button.height ? 0 : (mouseY < sliderbar.height - button.height ? mouseY : sliderbar.height - button.height) list.contentY = pt / (sliderbar.height - button.height) * (list.contentHeight - list.visibleArea.heightRatio * list.contentHeight) } } // 按钮 Rectangle { id: button x: 0 y: list.contentY /(list.contentHeight - (lis 4000 t.visibleArea.heightRatio * list.contentHeight)) * (sliderbar.height - button.height) width: parent.width height: list.visibleArea.heightRatio * sliderbar.height < (list.visibleArea.heightRatio * list.contentHeight)/5 ? (list.visibleArea.heightRatio * list.contentHeight)/5 : list.visibleArea.heightRatio * sliderbar.height; color: "#4cffffff" radius: 1 // 鼠标区域 MouseArea { id: mouseArea anchors.fill: button drag.target: button drag.axis: Drag.YAxis drag.minimumY: 0 drag.maximumY: sliderbar.height - button.height // 拖动 onMouseYChanged: { var pt = button.y list.contentY = pt / (sliderbar.height - button.height) * (list.contentHeight - list.visibleArea.heightRatio * list.contentHeight) } } } } }
相关文章推荐
- qml 自定义滑动条(官方example)
- QML 自定义Slider
- Android 自定义 HorizontalScrollView 打造再多图片(控件)也不怕 OOM 的横向滑动效果
- Android自定义左右滑动的跑马灯
- qml demo分析(objectlistmodel-自定义qml数据)
- Android中自定义滑动条风格
- Android之自定义(上方标题随ViewPager手势慢慢滑动)
- 自定义Layout用ViewGroup+ListView+GridView进行滑动事件拦截
- android自定义View之仿通讯录侧边栏滑动,实现A-Z字母检索
- 解决ScrollView和GridListView和ListView滑动冲突方法(二)自定义ListView和GridView
- andorid自定义ViewPager之——子ViewPager滑到边缘后直接滑动父ViewPager
- TabLayout的自定义实现选项卡背景的滑动动画
- IndicatorSeekBar:Android自定义View,滑动显示进度气泡指示器
- 自定义RecyclerView 支持 横向纵向,滑动删除Item
- VC++中轻松实现滑动(Slider)控件
- 实现可自定义的Android滑动删除
- 自定义viewGroup+ViewDragHelper: 仿探探主页卡片式滑动,层叠布局
- QML中的Component使用--自定义一个,然后使用它
- Android ViewPager动态向前向后加载数据,自定义viewPager滑动速度
- 自定义的带tab的可左右滑动的viewpager之二viewpager与fragment不兼容