views:

31

answers:

1

Hi,

I'm trying to create a simple QML application that will get an RSS feed with my active chess games and do stuff with it. At this point I am just trying to populate a list view with the feed contents, but it only shows one item even when there should be 11 items in the feed. Is this a bug or am I not getting something right?

Here's the code:


    import Qt 4.7
    import "content"

    Rectangle {
        id : window;
        width : 320
        height : 480

        XmlListModel {
            id : xmlModel

            source : "http://gameknot.com/rss.pl?n=kEzvYvEgfHoOmzQzQlY/5w5ITO5YDN"
            query : "/rss/channel/item"

            XmlRole { name: "title"; query: "title/string()"}
            XmlRole { name: "description"; query: "description/string()"}
        }

        Column
        {
            id : mainContainer

                ListView
                {

                    id : list
                    model : xmlModel
                    delegate : ListDelegate { }
                    //delegate: Text { text: title }
                }
        }
    }

The delegate should be all right, because the same thing also happens with the simple delegate I have commented out.

+1  A: 

Your model and view are fine, it's your layout that's wrong. Try adding anchors.fill: parent to mainContainer. That should fix it:

Column
{
    anchors.fill: parent
    id : mainContainer

    ListView
    {
        width: parent.width
        height: parent.height

        id : list
        model : xmlModel
        delegate : ListDelegate { }
        //delegate: Text { text: title }
    }
}
Stu Mackellar
Thanks, that's the ticket! Only anchors.fill: parent needs to be added to both the Column and ListView elements. The layout stuff is clearly my weakest area in Qt...
teukkam