table view
[mdictionary] / src / mdictionary / qml / ScrollBar2.qml
1 import Qt 4.7
2
3 Item {
4     id: scrollBar
5
6     // The properties that define the scrollbar's state.
7     // position and pageSize are in the range 0.0 - 1.0.  They are relative to the
8     // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
9     // of the height of the view.
10     // orientation can be either Qt.Vertical or Qt.Horizontal
11     property variant orientation : Qt.Vertical
12     property int windowHeight :100
13     property alias position: slider.x
14
15     signal changeCursor
16
17     // Size the bar to the required size, depending upon the orientation.
18     Rectangle {
19         id: slider;
20         width:  1;
21         height: windowHeight;
22         radius: height/2 - 1
23         color: "black"
24         opacity: 0.7
25     }
26
27     MouseArea {
28             property variant lastPresX;
29             anchors.rightMargin: 5
30             anchors.leftMargin: 5
31             id: mouse_area1
32             anchors.fill: slider
33             onEntered: {
34
35             }
36
37             onMousePositionChanged:{
38                 var num=0;
39                 if(Qt.LeftButton) {
40                     num= slider.x+(mouseX-lastPresX);
41
42                     if(num>(scrollBar.width-slider.width))
43                         slider.x=scrollBar.width-slider.width
44                     else if(num<0)
45                         slider.x=0;
46                     else
47                         slider.x=num ;
48                 }
49             }
50             onPressed: lastPresX=mouseX;
51         }
52 }