QtQuick学习笔记之QML布局定位器Row/Column/Grid/Flow

记录Qtquick核心编程学习内容:

组件ColorPicker在前面章节写了 http://blog.csdn.net/xuqiang918/article/details/51672479 的ColorPicker.qml中

import QtQuick 2.5
import QtQuick.Controls 1.4
Rectangle
{
    id:root;
    color:"#EEEEEE";
    width:400;
    height:300;
    Text {
        id:colorText;
        text: "Hello world";
        anchors.centerIn: parent;
        font:{bold:true; pixelSize:24}
    }
 
    function setTextColor(clr) {
        colorText.color = clr;
    }
    Row {
        anchors.left: parent.left;
        anchors.leftMargin: 10;
        anchors.bottom: parent.bottom;
        anchors.bottomMargin: 10;
        spacing: 4;
        ColorPicker {
            color:Qt.rgba(Math.random(), Math.random(), Math.random(), 1.0);
            onColorPicked: {
                setTextColor(clr);
            }
        }
        ColorPicker {
            color:Qt.rgba(Math.random(), Math.random(), Math.random(), 1.0);
            onColorPicked: {
                setTextColor(clr);
            }
        }
        ColorPicker {
            color:Qt.rgba(Math.random(), Math.random(), Math.random(), 1.0);
            onColorPicked: {
                setTextColor(clr);
            }
        }
        ColorPicker {
            color:Qt.rgba(Math.random(), Math.random(), Math.random(), 1.0);
            onColorPicked: {
                setTextColor(clr);
            }
        }
    }
}
 
 
 
 

Row和Column类似:都有spacing代表Item元素间隔距离, 都有add 、move、populate等属性


Grid无非多了这些属性:

        rows: 3;
        columns: 3;
        rowSpacing: 4;
        columnSpacing: 4;
Flow和Grid差不多,只是它自身会计算每个Item的大小再作相应的调整: 
有sapcing 属性

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值