美文网首页
17--Qt基本元素初体验--使用锚布局

17--Qt基本元素初体验--使用锚布局

作者: lvyweb | 来源:发表于2019-05-30 16:26 被阅读0次

标签(空格分隔): Qt


anchors提供了一种方式,让你可以通过指定一个元素与其他元素的关系来确定元素在界面中的位置。

一个使用锚布局的小例子

import QtQuick 2.0
import QtQuick.Controls 1.2

Rectangle {
    anchors.centerIn: parent;
    width: 600;
    height: 400;
    Rectangle {
        id:rect1;
        width: 220;
        height: 220;
        anchors.left: parent.left;
        anchors.leftMargin: 20;
        anchors.top: parent.top;
        anchors.topMargin:20;
        color:"pink";
    }
    Rectangle {
        width: 220;
        height: 220;
        anchors.left: rect1.right;
        anchors.leftMargin: 20;
        anchors.top: rect1.top;
        rotation:90;
        color:"skyblue";
    }

}


效果如下图


锚布局.png

相关文章

网友评论

      本文标题:17--Qt基本元素初体验--使用锚布局

      本文链接:https://www.haomeiwen.com/subject/kipvtctx.html