TextEdit {
id: textEdit
text: ""
font.pointSize: 14
height: contentHeight
width: frame.width - vbar.width
y: -vbar.position * textEdit.height
wrapMode: TextEdit.Wrap
selectByKeyboard: true
selectByMouse: true
MouseArea{
anchors.fill: parent
onWheel: {
if (wheel.angleDelta.y > 0) {
vbar.decrease();
}
else {
vbar.increase();
}
}
onClicked: {
textEdit.forceActiveFocus();
}
}
}
ScrollBar {
id: vbar
hoverEnabled: true
active: hovered || pressed
orientation: Qt.Vertical
size: frame.height / textEdit.height
width: 10
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
}
show.gif
需要完整代码请访问QtQuickExamples
网友评论