import Qt 4.7 Item { id: scrollBar // The properties that define the scrollbar's state. // position and pageSize are in the range 0.0 - 1.0. They are relative to the // height of the page, i.e. a pageSize of 0.5 means that you can see 50% // of the height of the view. // orientation can be either Qt.Vertical or Qt.Horizontal property variant orientation : Qt.Vertical property int windowHeight :100 property alias position: slider.x signal changeCursor // Size the bar to the required size, depending upon the orientation. Rectangle { id: slider; width: 1; height: windowHeight; radius: height/2 - 1 color: "black" opacity: 0.7 } MouseArea { property variant lastPresX; anchors.rightMargin: 5 anchors.leftMargin: 5 id: mouse_area1 anchors.fill: slider onEntered: { } onMousePositionChanged:{ var num=0; if(Qt.LeftButton) { num= slider.x+(mouseX-lastPresX); if(num>(scrollBar.width-slider.width)) slider.x=scrollBar.width-slider.width else if(num<0) slider.x=0; else slider.x=num ; } } onPressed: lastPresX=mouseX; } }