Flickable -- 内容拖拽,上下以及左右拖动进度条

Flickable:将子元素设置在可以拖动的界面上,当元素显示不全时,我们可以通过拖动查看其不同的部分。

  • 属性
    • width:显示窗口的宽度
    • height:显示窗口的高度
    • contentWidth:可拖拽的宽度
    • contentHeight:可拖拽的高度
    • clip:true大于显示窗口的部分被隐藏,可以通过拖动来显示未显示的部分。
    • visibleArea:可视区域
      • heightRatio:可视窗口高度占整个视图高度(height)的百分比
      • yPosition:可视窗口y方向位置占整个视图高度(height)的百分比
      • widthRatio:可视窗口宽度占整个视图高度(width)的百分比
      • xPosition:可视窗口x方向位置占整个视图宽度(width)的百分比
大于窗口的内容被隐藏
import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    minimumWidth: 1280
    minimumHeight: 960
    visible: true

    Flickable{
        width:              400
        height:             400
        contentWidth:       image.width
        contentHeight:      image.height
        clip:               true

        Image {
            id: image
            source: "Garland.jpg"
        }
    }
}
对窗体显示添加进度条
import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    minimumWidth: 1280
    minimumHeight: 960
    visible: true

    //-----------------------------------------
    Rectangle{
        width:              600
        height:             600
        anchors.top:        parent.top
        anchors.left:       parent.left
        anchors.leftMargin: parent.width / 2 - image.width / 2
        anchors.topMargin:  parent.height / 2 - image.height / 2


        Flickable{
            id:                 flick
            width:              400
            height:             400
            contentWidth:       image.width
            contentHeight:      image.height
            clip:               true

            Image {
                id: image
                source: "Garland.jpg"
            }
        }

        Rectangle{
            anchors.right:      flick.right
            width:              8
            height:             flick.visibleArea.heightRatio * flick.height
            y:                  flick.visibleArea.yPosition * flick.height
            color:              "gray"
        }

        Rectangle{
            anchors.bottom:     flick.bottom
            height:              8
            width:             flick.visibleArea.widthRatio * flick.width
            x:                  flick.visibleArea.xPosition * flick.width
            color:              "gray"
        }
    }
    //-------------------------------------------------------------------
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值