QT QML基础知识

QML好处:跨平台移植性、开发的开放性、开发者效率

1、QML语言提供基本数据类型:date 、size、 opint、 rect、color、font。还有基本对象类型:String Date、Timer等。

QT Quick子模块:Window、Layouts、Dialogs、XML、List、Mode1 

2、每个QML文档由两部分组成
import(导入需要的Qt Quick库),比如import QtQuick2.3
对象声明:是QML程序主体部分

3、QML基本语法
         对象和属性:以大写字母开头,后面跟一对大括号{},{}之中是该对象的属性,属性以键值对”属性名:值“的形式
          对象标识符:每个对象都可以指定一个唯一的id值,这样便可以在其他对象中识别并引用对象

4、注释QML文档注释同C/C++、JavaScript代码注释一样:
(1)单行注释使用"//"开始,在行末尾结束
 (2)多行注释使用"/*"开始,使用"*/"结尾

5、QML元素
a.Image(图像元素)

添加图标

b.Rectangle(矩形元素)

c.Text(文本元素)

d.Button(按钮元素)

e.BusyIndicator(繁忙指示器)

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0
Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    BusyIndicator
    {
    id:mybusuIndicator

    //anchors:瞄点布局
    anchors.centerIn: parent //把子类的控件放到父类的中心
    implicitWidth: 200
    implicitHeight: 200

    contentItem: Item {
        Rectangle{
        id:myrect
        width:parent.width
        height: parent.height
        color: Qt.rbra(0,0,0,0)
        radius: width/2
        border.width: width/8//数字越大圆圈越小
        visible: false;//边框是否见
        }
        ConicalGradient
        {
        width: myrect.width
        height: myrect.height
        gradient: Gradient
        {
            GradientStop{position: 0.0;color:"chartreuse"}//圆圈颜色
            GradientStop{position: 1.0;color:"orange"}//跟踪圆圈旋转后的颜色
        }
        source: myrect
        Rectangle{
            anchors.top:parent.top
            anchors.horizontalCenter: parent.horizontalCenter
            width: myrect.border.width
            height: width
            radius:width /2
            color:"red"
        }
        RotationAnimation on rotation {
            from: 0
            to:360
            duration: 2000
            loops: Animation.Infinite//循环
        }
        }
    }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值