QML Flickable 元素基本介绍

注意:由于一个实现的细节,放置在Flickable里面的项不能用id来anchor,而用parent代替。
----------------------------------------
Flickable 元素继承自Item,被ListView和GridView继承


Flickable提供一个较小的视窗来显示一个较大的内容给用户,并且用户可以对改内容进行拖拽和轻拂。


接下来为大家说明一下Flickable 的一些常用属性


-------------------------------------------
contentHeight : real
contentWidth : real
height
width
contentHeight 和contenWidth的值为实数,表示的显示内容的大小
height和width是视窗的大小。


----------------------------------------
contentItem : Item read-only
The internal item that contains the Items to be moved in the Flickable.
Items declared as children of a Flickable are automatically parented to the Flickable's contentItem.
Items created dynamically need to be explicitly parented to the contentItem.


------------------------------------------
contentX : real
contentY : real
这个属性返回内容被轻拂时,x,y方向(相对视窗左上角那个点)的位移。
例如,如果你把图片垂直挪动100像素点,则contentY的值将变为100


---------------------------------------------
flicking : bool
flickingHorizontally : bool
flickingVertically : bool
这三个为只读属性,返回当前视窗下,内容是否被轻拂(轻弹),如果有,flicking返回true,
如果是沿竖直方向对内容操作,则 flickingVertically 返回true, flickingHorizontally 返回false
如果是沿水平方向对内容操作,则 flickingHorizontally 返回true, flickingVertically 返回false


-----------------------------------
horizontalVelocity : real
verticalVelocity : real


这两个是只读属性,放回当前视窗下,内容被轻拂(轻弹)时,x,y方向的速度,单位是秒每像素点


-----------------------------------
maximumFlickVelocity : real
这个属性可以限定当前视窗下,内容被轻拂的最大速度,由实现平台限定默认值


----------------------------------
moving : bool
movingHorizontally : bool
movingVertically : bool
这三个为只读属性,返回当前视窗下,内容是否被拖动,如果有, moving 返回true,
如果是沿竖直方向对内容操作,则 movingVertically 返回true, movingHorizontally 返回false
如果是沿水平方向对内容操作,则 movingHorizontally 返回true, movingVertically 返回false


------------------------------------------------
用来做滚动条的
visibleArea.heightRatio : real
visibleArea.widthRatio : real
visibleArea.xPosition : real
visibleArea.yPosition : real
这四个为只读属性
这些属性描述的是当前视窗下,内容的区域的位置和大小
visibleArea.heightRatio = height / contenHeight 比例
visibleArea.widthRatio  = width / contentWidth 比例
visibleArea.xPosition = 
visibleArea.yPosition = 


还是看个实例吧

Rectangle {
     width: 200; height: 200


     Flickable {
         id: flickable
         ...
     }


     Rectangle {
         id: scrollbar
         anchors.right: flickable.right
         y: flickable.visibleArea.yPosition * flickable.height
         width: 10
         height: flickable.visibleArea.heightRatio * flickable.height
         color: "black"
     }
 }
 



---------------------------------------------------------
atXBeginning : bool
atXEnd : bool
atYBeginning : bool
atYEnd : bool
这些属性都为真,如果视窗的内容刚好与视窗大小相符
These properties are true if the flickable view is positioned at the beginning, or end respecively.


------------------------------------------
flickDeceleration : real
让轻拂或拖动的速率减慢


---------------------------------------
flickableDirection : enumeration
这个属性决定当前视窗的内容可以被操作的方向
This property determines which directions the view can be flicked.


Flickable.AutoFlickDirection (default) - 自动确定
Flickable.HorizontalFlick - 只允许水平操作
Flickable.VerticalFlick - 只允许垂直操作
Flickable.HorizontalAndVerticalFlick - 运行水平和垂直方向的操作


-----------------------------------------------
pressDelay : int


这个属性设置一个毫秒来延迟一个按钮到达视窗内的子项
This property holds the time to delay (ms) delivering a press to children of the Flickable. 
这可能是有用的,反应前的新闻一闪的行动有着不良的影响。
This can be useful where reacting to a press before a flicking action has undesirable effects.
这可能是有用的,因为在响应一个按钮之前,一个轻拂动作会导致不良的效果


---------------------------------------------------
interactive : bool
这个属性描述用户能否与当前视窗进行交互。当视窗不能进行交互(属性值为false),用户不能拖或者轻弹视窗内容
通常,这个属性的值为真


------------------------------------------------
boundsBehavior : enumeration
这个属性记录了当前视窗内容的大小超过了视窗的边界还是轻拂时越过视窗边界。
这使得边界实现羽化和柔和
boundsBehavior 可能是下面其中一个


Flickable.StopAtBounds - 内容不能被拖出视窗边界,轻拂时内容也不会超出视窗边界
Flickable.DragOverBounds - 内容能被拖出视窗边界,轻拂时内容也不会超出视窗边界
Flickable.DragAndOvershootBounds (default) - 内容能被拖出视窗边界,轻拂时内容会超出视窗边界


-----------------------------------------
contentItem : Item


交互项被包含进视窗,能被操作移动
交互项被声明为视窗的子,被自动添加到视窗的contentItem属性中去


Items created dynamically need to be explicitly parented to the contentItem:

Flickable {
     id: myFlickable
     function addItem(file) {
         var component = Qt.createComponent(file)
         component.createObject(myFlickable.contentItem);
     }
 }

 
--------------------------------------


*******************************************
信号处理器
-------------------------------------
onFlickEnded
当视窗内容被轻拂后停止,触发
This handler is called when the view stops moving due to a flick.


-------------------------------------
onFlickStarted
当视窗内容刚被被轻拂时,触发


This handler is called when the view is flicked. 


A flick starts from the point that the mouse or touch is released, while still in motion.
onFlickStarted




--------------------------------------
onMovementEnded
当视窗内容停止移动时,触发
This handler is called when the view stops moving due to user interaction. 
如果是轻拂,则这个信号处理器将在 轻拂之后停止滑动 被触发
If a flick was generated, this handler will be triggered once the flick stops. 
如果不是轻拂,当用户停止拖拽时被触发
If a flick was not generated, the handler will be triggered when the user stops dragging - i.e. a mouse or touch release.


--------------------------------------------
onMovementStarted
视窗内容刚被操作时触发
This handler is called when the view begins moving due to user interaction.




****************************************
This documentation is under development and is subject to change.
方法文档
-------------------------------------------------
Flickable::resizeContent ( real width, real height, QPointF center )
用于重置视窗内容尺寸


重置视窗内容尺寸会导致内容超过视窗的边界,使用returnToBounds() 函数可以修复内容的边界到一个合法的范围


------------------------------------------------------
Flickable::returnToBounds ()


使用returnToBounds() 函数可以修复内容的边界到一个合法的范围
  • 5
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
为了使更多的Qt初学者能尽快入门Qt,也为了QtQt Creator的快速普及,我们花费大量精力写出了这一系列教程。虽然教程的知识可能很浅显,虽然教程的语言可能不规范,但是它却被数十万网友所认可。我们会将这一系列教程一直写下去,它将涉及Qt的方方面面 一、Qt Creator的安装和hello world程序的编写 二、Qt Creator编写多窗口程序 三、Qt Creator登录对话框 四、Qt Creator添加菜单图标 五、Qt Creator布局管理器的使用 六、Qt Creator实现文本编辑 七、Qt Creator实现文本查找 八、Qt Creator实现状态栏显示 九、Qt Creator中鼠标键盘事件的处理实现自定义鼠标指针 十、Qt Creator中实现定时器和产生随机数 十一、Qt 2D绘图(一)绘制简单图形 十二、Qt 2D绘图(二)渐变填充 十三、Qt 2D绘图(三)绘制文字 十四、Qt 2D绘图(四)绘制路径 十五、Qt 2D绘图(五)显示图片 十六、Qt 2D绘图(六)坐标系统 十七、Qt 2D绘图(七)Qt坐标系统深入 十八、Qt 2D绘图(八)涂鸦板 十九、Qt 2D绘图(九)双缓冲绘图简介 二十、Qt 2D绘图(十)图形视图框架简介 二十一、Qt数据库(一)简介 二十二、Qt数据库(二)添加MySQL数据库驱动插件 二十三、Qt数据库(三)利用QSqlQuery类执行SQL语句(一) 二十四、Qt数据库(四)利用QSqlQuery类执行SQL语句(二) 二十五、Qt数据库(五)QSqlQueryModel 二十六、Qt数据库(六)QSqlTableModel 二十七、Qt数据库(七)QSqlRelationalTableModel 二十八、Qt数据库(八)XML(一) 二十九、Qt数据库(九)XML(二) 三十、Qt数据库(十)XML(三) 三十一、Qt 4.7.0及Qt Creator 2.0 beta版安装全程图解 三十二、第一个Qt Quick程序(QML程序) 三十三、体验QML演示程序 三十四、Qt Quick Designer介绍 三十五、QML组件 三十六、QML项目之Image和BorderImage 三十七、Flipable、Flickable和状态与动画 三十八、QML视图 三十九、QtDeclarative模块 四十、使用Nokia Qt SDK开发Symbian和Maemo终端软件 四十一、Qt网络(一)简介 四十二、Qt网络(二)HTTP编程 四十三、Qt网络(三)FTP(一) 四十四、Qt网络(四)FTP(二) 四十五、Qt网络(五)获取本机网络信息 四十六、Qt网络(六)UDP 四十七、Qt网络(七)TCP(一) 四十八、Qt网络(八)TCP(二)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值