2014-09-21 88 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" } 
    } 
}