qml中,普通的属性,需要添加属性名称,属性内容,如

color: “red”

默认属性则可以直接书写,去掉方括号,在写重用的QML组件式比较有用,例如将一个QmL外部资源封装好,内部具体的item,有子对象去填充。见代码

MyColumn.qml文件:

import QtQuick 2.0


Item
{
    default property alias col: myCol.children
    Column {
        id:myCol
        anchors.fill: parent

    }
}
 
main文件:
 

import QtQuick 2.2


Rectangle {
    id:root
    width: 860
    height: 860

    MyColumn
    {        
        anchors.fill: parent
        Rectangle
        {
            color:"red"
            width: 100; height:100
        }
        Rectangle
        {
            color:"green"
            width: 100; height:200
        }
        Rectangle
        {
            color:"blue"
            width: 100; height:100
        }

    }


}

参考:http://developer.blackberry.com/native/documentation/cascades/ui/custom_components/

QML的默认属性default property的更多相关文章

  1. How to: Initialize Business Objects with Default Property Values in XPO 如何:在 XPO 中用默认属性值初始化业务对象

    When designing business classes, a common task is to ensure that a newly created business object is ...

  2. How to: Initialize Business Objects with Default Property Values in Entity Framework 如何:在EF中用默认属性值初始化业务对象

    When designing business classes, a common task is to ensure that a newly created business object is ...

  3. iOS @property的默认属性

    我是一个比较懒的人,很多情况下@property都不喜欢加属性…所以必须了解默认情况下哪些是已经有的,哪些在需要时是必须要加的. 原文链接:http://blog.sina.com.cn/s/blog ...

  4. Android属性(property)机制

    1. 属性简介 Android里有很多属性(property),每个属性都有一个名称和值,他们都是字符串格式.这些属性定义了Android系统的一些公共系统属性.比如: [dalvik.vm.dexo ...

  5. VB默认属性、动态数组、Range对象的默认属性的一点不成熟的想法

    1.默认属性 VB6.0有默认属性的特性.当没有给对象指定具体的属性时,"默认属性"是VB6.0将使用的属性.在某些情形下,省略常用属性名,使代码更为精简. 因为CommandBu ...

  6. 查看特定View的默认属性值

    当我在分析focus.touch事件处理代码时发现,有些属性对代码的逻辑有非常重要的影响,比如clickable.focusable 这些属性.这时我们自然而然的想到,那么这些属性的默认值是什么呢?在 ...

  7. Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation

    程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...

  8. Objective-C:属性(@property)

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  9. TypeScript 3.0下react默认属性DefaultProps解决方案

    ts和react的默认属性的四种解决方案 Non-null assertion operator(非空断言语句) Component type casting(组件类型重置) High order f ...

随机推荐

  1. java之IO整理(上)

    /*//创建一个新文件 public static void main(String[] args) { File file=new File("D:\\hello.txt"); ...

  2. 大端模式、小端模式和C#反转

    A.C#大端模式和小端模式. 小端(little-endian)模式:低地址上存放低字节,高地址上存放高字节. 如0x11223344→ byte[] numBytes = new byte[]{ 0 ...

  3. Monkey测试工具介绍

    ---------------------------------------------------------------------------------------------------- ...

  4. TCP的交互数据流

    在TCP进行数据传输时,可以分为成块数据流和交互数据流两种,如果按字节计算,成块数据与交互数据的比例约为90%和10%,TCP需要同时处理这两类数据,且处理的算法不同. 书籍本章中以Rlogin应用为 ...

  5. 读《分布式一致性原理》zookeeper运维

    1.配置详解 1.1基本配置 基本参数包括clientPort,dataDir和tickTime 1.2高级配置 下面我们再来看看zookeeper中一些高级配置参数的配置实用 2.四字命令 我们曾经 ...

  6. python 监控windows磁盘空间和备份大小

    #!/usr/bin/env python # Version = 3.5.2 # __auth__ = '无名小妖' import os import time import sendmail im ...

  7. Windows Ruby 安装步骤

    by 狂奔的蜗牛的博客 from http://www.host900.com/ 本文地址:http://www.host900.com/index.php/articles/285/ Windows ...

  8. a+b_1

    题目截图: 思路: 直接输出即可. 代码如下: /* a+b */ #include <stdio.h> #include <string.h> #include <ma ...

  9. Redis AOF 全持久化

    简介: Redis AOF 持久化,将每次接收到更改 redis 数据的操作都记录到一个 aof 文件,当服务器意外宕机或 redis 服务器非法关闭时,不会丢失数据. 可以做到数据安全化,但是性能会 ...

  10. Memcache 内存对象缓存系统

    简介: Memcached 是一个高性能的分布式内存存储对象缓存系统,用于动态 WEB 应用以减轻数据库负载. 它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态.数据库驱动网站的速度. ...