qt - QML SwipeView is covering entire window -


i having problems if use swipe view , have written following code:

import qtquick 2.6 import qtquick.window 2.2 import qtquick.controls 2.2  window {     visible: true     width: 640     height: 480     title: qstr("swipe view")      mainform {         anchors.fill:parent          rectangle{             id:rightrect             anchors.right:parent.right             width: parent.width*0.50             height:parent.height             color:"yellow"         }          rectangle{             id:leftrect             width:parent.width*0.50             height:parent.height             color:"lightgreen"             border.color:"red"             anchors.right:rightrect.left             swipeview{                 id:swipeview                 anchors.fill : leftrect                 //layout.fillwidth: true                 currentindex: 0                 interactive: false                 page{                     id:page1                      rectangle{                         width:parent.width                         height:parent.height                         color:"lightgreen"                         button{                             text:"move 2"                             onclicked: swipeview.currentindex = 1                         }                     }                 }                  page{                     id:page2                     rectangle{                         width:parent.width                         height:parent.height                         color:"lightblue"                         button{                             text:"move 1"                             onclicked: swipeview.currentindex = 0                         }                     }                 }             }         }     } } 

below screen shots:

1) have set current index "0" index "1" blue area visible , it's covering right area(yellow rectangle):

enter image description here

2) if click on move 2 button yellow rect visible expected.

enter image description here

now, if click on move 1 button need same behavior ie., yellow rect should visible time.how achieve ??

add clip:true parent of swipeview , good.

rectangle{             id:leftrect             width:parent.width*0.50             height:parent.height             color:"lightgreen"             border.color:"red"             anchors.right:rightrect.left             clip:true    //add             swipeview{ 

according qt documentation

if clipping enabled, item clip own painting, painting of children, bounding rectangle.

by default value false hence swipeview goes out of rectangle area.


Comments