[SailfishDevel] Problem with Repeater and component

Rafal Zawadzki bluszcz at bluszcz.net
Sat Mar 7 03:02:19 UTC 2015


Dear sailors,

I am relatively new to QML and I am trying to achieve  following 
layout:

Label
[ Image ]

Label
[ Image ]

and I am trying to do it with Repeater and Component (I use Component / 
Rectangle to aggrate two elements for repeater - not sure if this is 
correct).

However, it shows only one last element - image, without label, on top 
of the screen :/

Any help would be appreciated.

<code>
import QtQuick 2.0
import Sailfish.Silica 1.0

Page {
     id: page
     SilicaFlickable {
         anchors.fill: parent

         PullDownMenu {
             MenuItem {
                 text: qsTr("Credits")
                 onClicked: 
pageStack.push(Qt.resolvedUrl("Credits.qml"))
             }
         }

         contentHeight: column.height

         Column {
             id: column
             width: page.width
             spacing: Theme.paddingLarge
             PageHeader {
                 title: qsTr("Veggie Sailor")
             }


             Repeater {
                 id: repeater
                 width: page.width
                 model: ListModel {
                     ListElement {
                         mytext: "Barcelona"
                         image: "qrc:///static/images/barcelona.jpg"
                     }
                     ListElement {
                         mytext: "Copenhagen"
                         image: "qrc:///static/images/copenhagen.jpg"
                     }
                 }
                 delegate: customblock
             }
             Component {
                 id: customblock
                 Rectangle {
                     Label {
                         text: qsTr(mytext)
                         color: Theme.secondaryHighlightColor
                         x: Theme.paddingLarge

                     }
                     Image {

                         width: column.width
                         height: 200
                         fillMode: Image.PreserveAspectCrop
                         source: image
                     }
                 }
             }
         }
     }
}
</code>
-- 
Rafal bluszcz Zawadzki
https://picup.it
https://bluszcz.net
https://jabberpl.org


More information about the Devel mailing list