查看完整版本: [-- zhengtianzuo系列-QmlTextEdit带滚动条 --]

QTCN开发网 -> Qt代码秀 -> zhengtianzuo系列-QmlTextEdit带滚动条 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

zhengtianzuo 2017-10-20 14:38

zhengtianzuo系列-QmlTextEdit带滚动条

```
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

big_mouse 2020-04-22 09:21


查看完整版本: [-- zhengtianzuo系列-QmlTextEdit带滚动条 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled