Spacer element in QML layouts

I want to create a layout in QML, and I would like to add a separator element (the bottom selected element in the image below) the same way you do it with widgets:

enter image description here

But I could not find anything to match this on the side of QtQuickthings ... is it possible to have such a layout in QMLwithout using a binding system? I would prefer a layout approach ...

+4
source share
1 answer

You can just use Itemwith Layout.fillHeight: true:

import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3

ApplicationWindow {
    visible: true
    ColumnLayout {
        anchors.fill: parent
        Button {
            Layout.fillWidth: true
            text: "PushButton"
        }
        Button {
            Layout.fillWidth: true
            text: "PushButton"
        }
        Label {
            Layout.fillWidth: true
            text: "TextLabel"
        }
        Item {
            // spacer item
            Layout.fillWidth: true
            Layout.fillHeight: true
            Rectangle { anchors.fill: parent; color: "#ffaaaa" } // to visualize the spacer
        }
    }
}

EDIT: Column spacer, Column , .

+10

Source: https://habr.com/ru/post/1666234/


All Articles