我正在尝试将GridLayout包装在Item中,并将GridLayout的data属性公开为该项的默认属性。但这会导致两个问题。
退出应用程序时出现崩溃。
如何使用附加的Layout属性?请查看以下示例,这会导致错误:
Non-existent attached object
在线
"Layout.alignment: Qt.AlignBottom | Qt.AlignRight".
示例:
//MyCustomLayout.qml
import QtQuick 2.7
import QtQuick.Layouts 1.3
Item {
default property alias data: layout.data
//Some other QML components not to be within GridView here.
GridLayout {
id: layout
anchors.fill: parent
}
//Some other QML components not to be within GridView here.
}
//main.qml
import QtQuick.Controls 2.0
ApplicationWindow {
id: root
visible: true
height: 1024
width: 768
MyCustomLayout {
anchors.fill: parent
Button {
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
}
}
}