[SOLVED] QML list of images not visible

Issue

I have not worked with QML lists much, but I have a QML parent Item that needs to draw a list of little tile images.

Whenever a QML Image is taken out of the list it is viewable but not while in the list.
(No compile-time or runtime warning or errors in either case)

Displays okay:

Item {
    id : player_health

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

Does not display (neither of these images):

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

I would like the images in the list to be visible but can’t find a way to do it via a list.

Solution

If you want beautiful place your pictures, then you can use simple positioner Row or Column. For example:

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

    }
}

Answered By – Kosovan

Answer Checked By – David Goodson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *