【问题标题】:how to use topMargin in ColumnLayout in QML如何在 QML 的 ColumnLayout 中使用 topMargin
【发布时间】:2015-10-29 17:36:09
【问题描述】:

我正在尝试在 ColumnLayout 中使用 topMargin。但我面临一些问题。 有人能帮我解决这个问题吗?

这是我的代码

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Layouts 1.1

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Rectangle{
        anchors.fill: parent
        ColumnLayout{
            id: columlayout
            Rectangle{
                width: 100
                height: 100
                color: "red"
            }
            Rectangle{
                Layout.topMargin: 50
                width: 100
                height: 100
                color: "green"
            }
            Rectangle{
                width: 100
                height: 100
                color: "blue"
            }
        }
    }
}

问题:

无法分配给不存在的属性“topMargin”

【问题讨论】:

    标签: qt qml


    【解决方案1】:

    margin properties 是在 QtQuick.Layouts 1.2 中引入的,因此您必须导入该版本,而不是 1.1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-15
      • 2016-06-04
      • 2015-08-19
      • 2018-08-09
      • 2018-12-02
      • 2014-03-14
      • 2021-11-09
      • 2021-05-10
      相关资源
      最近更新 更多