Jeggu
Jeggu

Reputation: 579

how to use topMargin in ColumnLayout in QML

I am trying to use topMargin in ColumnLayout. but i am facing some issues. Could some one help me out of this.

Here is my code

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"
            }
        }
    }
}

Issue:

Cannot assign to non-existent property "topMargin"

Upvotes: 1

Views: 1357

Answers (1)

Mitch
Mitch

Reputation: 24406

The margin properties were introduced in QtQuick.Layouts 1.2, so you must import that version, not 1.1.

Upvotes: 2

Related Questions