qml-LayoutMirroring镜像布局

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MyLovelyJay/article/details/87864348

LayoutMirroring附加属性用来在水平方向镜像项目锚布局、定位器和视图。镜像只是视觉上的变化,例如左侧布局变成右侧布局。
演示代码:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

ApplicationWindow {
    visible: true
    width: 480
    height: 360
    title: qsTr("LayoutMirroring")

    Rectangle{
        
        // LayoutMirroring.enabled设置为ture启用镜像
        LayoutMirroring.enabled:true
        // childrenInherit属性设置为true,那么该项目的所有子项目都会启用镜像
        LayoutMirroring.childrenInherit: true
        width:300; height:50
        color:"yellow"
        border.width: 1
        anchors.centerIn: parent
        Row{
            anchors{left:parent.left; margins:5}
            y:5; spacing: 5
            Repeater{

                 model:5
                 Rectangle{

                   color:"red"
                   opacity: (5 - index)/5
                   width:40; height:40
                   Text{
                        text: index +1
                        anchors.centerIn: parent
                   }
                 }
            }
        }
    }
}

效果展示:在这里插入图片描述
当把 LayoutMirroring.childrenInherit 设置为false时,显示效果如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/MyLovelyJay/article/details/87864348
QML