如何结合使用GridLayout和公开数据属性

时间:2017-01-24 18:38:09

标签: qt layout qml qtquick2 qtquickcontrols2

我正在尝试将GridLayout包装在Item中,并将GridLayout的data属性公开为该项的默认属性。但这会导致两个问题。

  1. 退出应用程序时出现崩溃。

    • 这可能实际上是Qt本身的一个错误,它也可能已经修复,如果不是我会在修复后报告它2.我只能在Windows 7上使用Qt 5.7.0 MSVC2015 32.bit at那一刻。
  2. 如何使用附加的Layout属性?请查看以下示例,这会导致错误:

    Non-existent attached object
    
  3. 在线

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

0 个答案:

没有答案
相关问题