After more digging, I found that Flickable was the way to go.
Flickable {
id: testFlick
boundsBehavior: Flickable.StopAtBounds
clip:true
x:100
y:100
width:200
height:200
contentWidth: 500
contentHeight: textBox.paintedHeight
focus:true
Keys.onPressed: {
console.log("keypress registered")
if(event.key == Qt.Key_Down){
testFlick.flick(0,-500);
}
else if(event.key == Qt.Key_Up){
testFlick.flick(0,500);
}
}
Text{
id: textBox
font.pointSize: 20
text: "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n";
}
}
Rectangle{
id: scrollbarBackground
anchors.right: testFlick.right
z: 1
width:10
y: testFlick.y
height: testFlick.height
color: "brown"
}
Rectangle {
id: scrollbar
anchors.right: testFlick.right
y:testFlick.visibleArea.yPosition * testFlick.height + testFlick.y
z: 2
width: 10
height: testFlick.visibleArea.heightRatio * testFlick.height
color: "black"
}
Flickable {
id: testFlick
boundsBehavior: Flickable.StopAtBounds
clip:true
x:100
y:100
width:200
height:200
contentWidth: 500
contentHeight: textBox.paintedHeight
focus:true
Keys.onPressed: {
console.log("keypress registered")
if(event.key == Qt.Key_Down){
testFlick.flick(0,-500);
}
else if(event.key == Qt.Key_Up){
testFlick.flick(0,500);
}
}
Text{
id: textBox
font.pointSize: 20
text: "test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n";
}
}
Rectangle{
id: scrollbarBackground
anchors.right: testFlick.right
z: 1
width:10
y: testFlick.y
height: testFlick.height
color: "brown"
}
Rectangle {
id: scrollbar
anchors.right: testFlick.right
y:testFlick.visibleArea.yPosition * testFlick.height + testFlick.y
z: 2
width: 10
height: testFlick.visibleArea.heightRatio * testFlick.height
color: "black"
}
To copy to clipboard, switch view to plain text mode
Bookmarks