2014-09-21 87 views
0

我還沒有與QML列表很多,但我有一個QMLItem需要繪製一個小瓦片圖像列表。QML圖像清單不可見

每當QMLImage被從列表中取出時,它是可見的,但不在列表中。 (在任何情況下沒有編譯時和運行時警告或錯誤)

顯示沒關係:

Item { 
    id : player_health 

    Image { 
     z:2; 
     height: 26; 
     width: 19; 
     x: 50; 
     y: 50; 
     source:"resources/gameplay/square_pink.png" 
    } 
} 

不顯示(無論這些圖像的):

Item { 
    id : player_health 

    property list<Image> bars: [ 
     Image { z:2; height: 26; width: 19; x: 50; y:50; source: "resources/gameplay/square_pink.png"}, 
     Image { z:2; height: 26; width: 19; x: 50; y:50; source: "resources/gameplay/square_blue.png"} 
    ] 
} 

我想列表中的圖像是可見的,但無法通過列表找到方法。

回答

1

如果你想美麗的地方你的照片,那麼你可以使用簡單的定位器或Column。例如:

Rectangle { 
    x: 8 
    y: 250 
    width: 320; height: 110 
    color: "black" 



    Row { 
     anchors.horizontalCenter: parent.horizontalCenter 
     anchors.verticalCenter: parent.verticalCenter 

     spacing: 5 

     Image { width: 100; height: 100; source: "images/earth.png" } 
     Image { width: 100; height: 100; source: "images/uranus.png" } 

    } 
} 
+0

感謝您指出我在正確的方向。由於我將使用常規間距,因此您的解決方案與我需要的接近。不過我認爲帶有直放站的網格更接近我所需要的(可能需要垂直和水平地一起/對角)。 – Willeman 2014-09-21 18:19:01

1
Item { 
    id : player_health 

    Grid { 

    rows: 5; columns: 1; spacing: 10 

    Repeater { model: 5 
       Image { z:2; height: 26; width: 19; x: 50; y:50; source:"resources/gameplay/square_pink.png" } 
    } 
}