博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QML如何实现窗口缩放隐藏
阅读量:3623 次
发布时间:2019-05-21

本文共 1622 字,大约阅读时间需要 5 分钟。

在这里插入图片描述

上面实现了窗口以矩形的方式进行缩放隐藏和显示。

实现介绍

该功能主要使用了QML动画中的NumberAnimation来实现,下面简单介绍一下NumberAnimation。

NumberAnimation顾名思义就是数字动画,可以改变类型为数值的属性,从而产生一系列的动画,例如,width,height,radius,scale等等。
相关属性介绍:

target: 目标easing.type: 动画播放形式,详情:https://www.xuebuyuan.com/146517.htmlproperties:  对应的属性,例如"width","scale","height","x","y"from: 启示状态值to: 终止状态值duration: 持续时间,单位ms

代码

import QtQuick 2.12import QtQuick.Controls 2.12import QtQuick.Window 2.12Window {
width:640 height:480 visible:true Rectangle{
id: root anchors.fill: parent color: "black" Rectangle {
id: rect1 radius: 20 width:root.width height:root.height color:"gray" NumberAnimation on scale {
to: 0; duration: 5000} } Button {
id:btn1 text: "disable" anchors.centerIn: parent onClicked: {
animation.start() } } Button {
id:btn2 text: "show" anchors.top: btn1.bottom anchors.topMargin: 20 anchors.left: btn1.left onClicked: {
animation2.start() } } NumberAnimation {
id: animation target: rect1 easing.type: Easing.InCubic properties: "scale" to: 0 duration: 500 } NumberAnimation{
id: animation2 target: rect1 easing.type: Easing.InCubic properties: "scale" to: 1 duration: 500 } }}

转载地址:http://cxuun.baihongyu.com/

你可能感兴趣的文章
第14课_Python 读取TXT文件
查看>>
第15课_Python 我的第一个爬虫软件
查看>>
第1课:零基础学PHP语言
查看>>
第2课:PHP变量与数据类型
查看>>
第3课:PHP条件语句和运算符应用
查看>>
第4课:PHP循环语句使用方法
查看>>
第5课:PHP的真正力量是函数
查看>>
第6课:郭盛华课程PHP字符串函数
查看>>
第7课:郭盛华课程PHP超全局变量
查看>>
第8课:郭盛华课程PHP制作一个简单的HTML表单
查看>>
第9课:郭盛华课程如何使用PHP来验证表单数据
查看>>
第10课:郭盛华课程PHP表单验证E-mail 和 URL
查看>>
第11课:郭盛华课程PHP获得简单的日期时间
查看>>
第12课:郭盛华课程PHP-Cookies存储的使用方法
查看>>
第13课:郭盛华课程PHP-Sessions存储的使用方法
查看>>
第14课:郭盛华课程PHP错误处理语句
查看>>
第15课:郭盛华课程PHP文件如何引入
查看>>
第0课:郭盛华课程_零基础学Visual Basic编程语言
查看>>
第1课:郭盛华课程_如何安装VB编程软件及新建标准EXE程序
查看>>
第2课:郭盛华课程_VB编程之常用重要函数
查看>>