如何让这个GridView出现在我的窗口中心?

时间:2017-10-21 17:34:36

标签: qt qml qtquick2

我现在卡在这个QML项目上。它是一个简单的2x3网格,似乎粘在屏幕的左边。如果我应用anchors.centerIn: parent,它会使GridView居中但忽略我的TopMargin属性。如果我能得到任何帮助,我们将不胜感激。我知道我可以应用一个leftMargin:但它有点难看。

GridView {

    id: gridView
    interactive: false
    clip: true

    // anchors.centerIn: parent
    anchors.left: parent.left
    anchors.top: titleBarContainer.bottom
    anchors.topMargin: 20
    anchors.right: parent.right

    width: 400
    height: parent.height

    currentIndex: -1

    cellWidth: 200
    cellHeight: 200

1 个答案:

答案 0 :(得分:0)

...

anchors.top: titleBarContainer.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter

width: 400
height: parent.height

...
相关问题