Solved Change layout attached properties
-
Hello,
I want to change mBlueRect Layout.maximumHeight property in main.qml how can this be accomplished?//main.qml import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 Test { anchors.fill: parent blueRect.Layout.maximumHeight: 100 //This doesn't work } }
//Test.qml import QtQuick 2.6 import QtQuick.Layouts 1.3 ColumnLayout { property alias blueRect: mBlueRect Rectangle { id: redRect Layout.fillHeight: true Layout.fillWidth: true color: "red" } Rectangle { id: mBlueRect Layout.fillHeight: true Layout.fillWidth: true Layout.maximumHeight: 20 color: "blue" } }
-
@Eligijus Try:
//main.qml ... Test { anchors.fill: parent maxH: 100 } ... //Test.qml ... ColumnLayout { property int maxH: 20 ... Layout.maximumHeight: maxH
-
@Eeli-K Thanks. But why can't I write something like this?
property alias myMax: Layout.maximumHeight
-
@Eligijus I think attached properties just behave differently. They are available only for the object they are attached to and can't be aliased, either. We have to live with that.
Syntactically and semantically this "Layout" or "Layout.maximumHeight" isn't a property of the object which uses it. Therefore you can't refer to it like to object's own properties.