Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QML图像列表不可见_Qt_List_Qml_Qt5 - Fatal编程技术网

Qt QML图像列表不可见

Qt QML图像列表不可见,qt,list,qml,qt5,Qt,List,Qml,Qt5,我没有使用过太多的QML列表,但是我有一个QMLparentItem,它需要绘制一个小平铺图像列表 无论何时从列表中取出QML图像,它都是可查看的,但在列表中时不可查看。 (两种情况下都没有编译时或运行时警告或错误) 显示正常: Item { id : player_health Image { z:2; height: 26; width: 19; x: 50; y: 50; so

我没有使用过太多的
QML
列表,但是我有一个
QML
parent
Item
,它需要绘制一个小平铺图像列表

无论何时从列表中取出
QML
图像
,它都是可查看的,但在列表中时不可查看。 (两种情况下都没有编译时或运行时警告或错误)

显示正常:

Item {
    id : player_health

    Image {
        z:2;
        height: 26;
        width: 19;
        x: 50;
        y: 50;
        source:"resources/gameplay/square_pink.png"
    }
}
不显示(这些图像都不显示):

项目{
id:player_health
属性列表栏:[
图片{z:2;高度:26;宽度:19;x:50;y:50;来源:“resources/gameplay/square_pink.png”},
图片{z:2;高度:26;宽度:19;x:50;y:50;来源:“resources/gameplay/square_blue.png”}
]
}

我希望列表中的图像可见,但找不到通过列表来实现的方法。

如果您想要漂亮地放置图片,则可以使用简单的定位器
。例如:

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

    }
}

谢谢你给我指明了正确的方向。您的解决方案接近我需要的,因为我将使用规则间距。然而,我认为一个带有中继器的网格更接近我所需要的(可能需要垂直和水平方向/对角线方向)。
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" }

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