2014-02-14 38 views
0

當我在ColumnLayout中放置多個圖像時,它們覆蓋自己,我只看到最後一個。QML/QtQuick - 在ColumnLayout中覆蓋的圖像

這裏是我的代碼示例:

Rectangle{ 
    width: parent.width 
    color: "#00ffffff" 
    height: 370 
    ColumnLayout{ 
     width : parent.width 
     spacing : 0 
     Image { 
      anchors.horizontalCenter: parent.horizontalCenter 
      anchors.verticalCenter: parent.verticalCenter 
      source: "img/img1.png" 
     } 
     Image { 
      anchors.horizontalCenter: parent.horizontalCenter 
      anchors.verticalCenter: parent.verticalCenter 
      source: "img/img2.png" 
    } 
     Image { 
      anchors.horizontalCenter: parent.horizontalCenter 
      anchors.verticalCenter: parent.verticalCenter 
      source: "img/img3.png" 
     } 
    } 
} 

你對我怎麼能設法看到3個圖像一個低於任何其他的想法?

回答

1

那是因爲你正迫使圖像垂直和水平居中時做此:

Image { 
    anchors.horizontalCenter: parent.horizontalCenter 
    anchors.verticalCenter: parent.verticalCenter 
    source: "img/img3.png" 
} 

如果你希望你的圖像水平居中,但在同一時間保持在列布局你應從您的Image組件中刪除anchors.verticalCenter財產

+0

謝謝!就是這樣。 我從我的Images組件中刪除了「anchors.verticalCenter」屬性,並將它放在上面的ColumnLayout中,並且這樣做。 謝謝。 – Pat