[Qt-qml] Repeater element missing the border between the items

Alan Alpert alan.alpert at nokia.com
Tue Apr 20 10:22:31 CEST 2010


 Tirsdag 20. april 2010 18:08:06 skrev ext Rakesh.Mutharaju at tieto.com :
> Hi,
> 
>         I have a similar type of list content, instead of rewriting them
> for n-number of times I used Repeater element, I noticed that the border
> or seperator between the items is lost.
> 
> For eg.,
> 
>                 Rectangle {
>                     id: myitemrect1
>                     x: 0
>                     y: 536
>                     width: parent.width
>                     height: 70
>                     color: "#babec1"
>                     border.color: "#7e7e7e"
>                     anchors.top: parent.top
>                     anchors.topMargin: 0
>                     Text {
>                         id: text13
>                         x: 46
>                         y: 20
>                         width: 255
>                         height: 40
>                         text: "item1"
>                         verticalAlignment: "AlignVCenter"
>                         anchors.top: parent.top
>                         anchors.topMargin: 15
>                         anchors.left: parent.left
>                         anchors.leftMargin: 50
>                         font.pointSize: 20
>                         font.bold: false
>                         font.family: "FreeSans"
>                     }
>                 }
>                 Rectangle {
>                     id: myitemrect2
>                     x: 0
>                     y: 591
>                     width: parent.width
>                     height: 70
>                     color: "#babec1"
>                     anchors.top: myitemrect1.bottom
>                     anchors.topMargin: 0
>                     border.color: "#7e7e7e"
>                     Text {
>                         id: text14
>                         x: 48
>                         y: 600
>                         width: 255
>                         height: 40
>                         text: "item2"
>                         anchors.top: parent.top
>                         anchors.topMargin: 15
>                         font.bold: false
>                         font.family: "FreeSans"
>                         font.pointSize: 20
>                         anchors.leftMargin: 50
>                         verticalAlignment: "AlignVCenter"
>                         anchors.left: parent.left
>                     }
>                 }
> ..
> 
> Above, code shows the border and works as expected. I replaced the above
> code with Repeater element like.,
> 
>                 Column {
>                     Repeater {
>                         model:8
>                         Rectangle {
>                             id: myitem
>                             x: 0
>                             y: 536
>                             width: parent.width
>                             height: 70
>                             color: "#babec1"
>                             border.color: "#7e7e7e"
>                             border.width: 5  --------------->>>>>> I tried
> increasing the width, even then border is not visible. Text {
>                                 id: text13
>                                 x: 46
>                                 y: 20
>                                 width: 255
>                                 height: 38
>                                 text: "item"+index
>                                 verticalAlignment: "AlignVCenter"
>                                 anchors.left: parent.left
>                                 anchors.leftMargin: 50
>                                 font.pointSize: 20
>                                 font.bold: false
>                                 font.family: "FreeSans"
>                             }
>                         }
>                     }
>                 }
> 
> Now, the border between the items is lost. Is there possibility to show the
> border if I use Repeater element? Thanks and Regards,
> Rakesh

I don't see anything wrong with the result of that code. Keep in mind that the 
border width is not added to the Rectangle's width. This means that since you 
don't specify any spacing on the Column, the rectangles will be drawn 
overlapping. Adding spacing equal to the border width would allow the full 
borders to be shown.

-- 
Alan Alpert
Software Engineer
Nokia, Qt Development Frameworks



More information about the Qt-qml mailing list