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. [转]自己做 Visual Studio 2013 代码折叠插件

    本文代码来自:https://msdn.microsoft.com/zh-cn/library/ee197665.aspx 第一步.引用 -> 程序集 -> 扩展 里找到对应 .dll 添 ...

  2. Log4j配置详解之log4j.xml

    Log4j配置详解之log4j.xml Log4J的配置文件(Configuration File)就是用来设置记录器的级别.存放器和布局的,它可接key=value格式的设置或xml格式的设置信息. ...

  3. BigDecimal求余操作

    BigDecimal求余操作如下: package com.qiu.lin.he; import java.math.BigDecimal; public class CeShi { public s ...

  4. python基础知识之列表、元祖、字典、集合、字符串。

    1.可变类型之列表 列表用 [ ]来定义是可变的,可以通过索引值来去查询里面的字段可以可以追加,删除等 names='zhangyang guyun xiangpeng xuliangwei' nam ...

  5. Python图片转字符

    前段时间学习pillow写的,可以通过改变font_map改变转换的深度和字符.思路是先转换黑白大小,读取黑白值取范围读font_map转变. from PIL import Image,ImageD ...

  6. new及placememt new 异同点

    new与定位new 区别如下: 简单概括: new 分配的内存地址空间来自于heap堆,用完需使用delete 释放内存 定位new 使用的不是heap堆内存,因此不需要使用delete 释放 定位n ...

  7. 比XGBOOST更快--LightGBM介绍

    xgboost的出现,让数据民工们告别了传统的机器学习算法们:RF.GBM.SVM.LASSO.........现在,微软推出了一个新的boosting框架,想要挑战xgboost的江湖地位.笔者尝试 ...

  8. ZooKeeper架构

    ZooKeeper服务器端运行于两种模式下:独立模式(standalone)和仲裁模式(quorum).独立模式几乎与其术语所描述的一样:有一个单独的服务器,ZooKeeper状态无法复制.在仲裁模式 ...

  9. halcon采集一幅图像

    **顺序也很重要,必须现有窗口,才能设置属性 dev_close_window()dev_open_window (0, 0, 1400, 1200, 'black', WindowHandle)de ...

  10. Django models拆分

    大多数Django教程都是将models放在models.py文件(模块)中, 然而随着models类的增加, 将类放在一个文件中太混乱了, 于是将models做成一个package: 这样就可以将m ...