QmlTextEdit带滚动条

来源:互联网 发布:安卓手机 mac照片 编辑:程序博客网 时间:2024/05/17 23:28
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          }

这里写图片描述

需要完整代码请访问QtQuickExamples