Na przykład to działa:Qt5 QML, kiedy używać kolumny ColumnLayout vs Column?
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.2
ApplicationWindow
{
visible: true
width: 640
height: 480
title: qsTr("Hello World")
function thingWidth()
{
return width*80/100
}
Column
{
spacing: 10;
anchors.horizontalCenter: parent.horizontalCenter
Thing { color: "red"; width: thingWidth(); }
Thing { color: "yellow"; width: thingWidth(); }
Thing { color: "green"; width: thingWidth(); }
}
}
jednak zmienić Column
do ColumnLayout
i nie (zmiany rozmiaru okna powoduje, że układ się nie udać).
każda pomoc, dzięki.
EDIT 1:
Tutaj też Thing.qml
zgodnie z wnioskiem,
import QtQuick 2.0
Item {
property alias color: rectangle.color
width: 50; height: 50
Rectangle
{
id: rectangle
border.color: "white"
anchors.fill: parent
}
}
Wygląda jak mój post jest głównie kod. Tak, niania to robi! to dlatego, że ludzie publikują tutaj kod.
Proszę albo a) podać kod dla 'Thing', lub b) zastąpić je czymś, do czego mamy dostęp, np.' Rectangle'. – Mitch
zrobione. Przepraszam za opiekuna –