Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ScrollView not working with TextEdit?
Forum Updated to NodeBB v4.3 + New Features

ScrollView not working with TextEdit?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    It worked with a 1.x version of the libraries, but 2.x is not letting me use scroll bars correctly. If the text goes off the end of the page it does not allow me to scroll.

    import QtQuick 2.12
    import QtQuick.Controls 2.5
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Scroll")
    
        ScrollView {
            anchors.fill: parent
    
            TextEdit {
                width: parent.width
    
                textFormat: Text.PlainText
                focus: true
                selectByMouse: true
    
                text: "asdf\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nasdf"
            }
        }
    }
    

    C++ is a perfectly valid school of magic.

    fcarneyF 1 Reply Last reply
    0
    • fcarneyF fcarney

      It worked with a 1.x version of the libraries, but 2.x is not letting me use scroll bars correctly. If the text goes off the end of the page it does not allow me to scroll.

      import QtQuick 2.12
      import QtQuick.Controls 2.5
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Scroll")
      
          ScrollView {
              anchors.fill: parent
      
              TextEdit {
                  width: parent.width
      
                  textFormat: Text.PlainText
                  focus: true
                  selectByMouse: true
      
                  text: "asdf\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nasdf"
              }
          }
      }
      
      fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Updated with scroll bar that worked with other objects like ListView:

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
          title: qsTr("Scroll")
      
          ScrollView {
              anchors.fill: parent
      
              ScrollBar.vertical: ScrollBar {
                  id: verticalBar
                  anchors.top: parent.top
                  anchors.bottom: parent.bottom
                  anchors.right: parent.right
                  hoverEnabled: true
                  active: hovered || pressed
      
                  property bool showIt: hovered || pressed
      
                  background: Rectangle {
                      implicitWidth: 25
                      implicitHeight: 40
                      radius: 5
                      color: verticalBar.showIt ? "grey" : "transparent"
                  }
      
                  contentItem: Item {
                      implicitWidth: 25
                      implicitHeight: 40
                      Rectangle {
                          anchors.fill: parent
                          anchors.topMargin: 6
                          anchors.leftMargin: 4
                          anchors.rightMargin: 4
                          anchors.bottomMargin: 6
                          radius: 10
                          color: verticalBar.showIt ? "#424246" : "transparent"
                      }
                  }
              }
      
              TextEdit {
                  width: parent.width
      
                  textFormat: Text.PlainText
                  focus: true
                  selectByMouse: true
      
                  text: "asdf\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nasdf"
              }
          }
      }
      

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        Gahhhh! It looks like I should be using a TextArea now:
        https://doc.qt.io/archives/qt-5.11/qml-qtquick-controls2-textarea.html

        C++ is a perfectly valid school of magic.

        T 1 Reply Last reply
        0
        • fcarneyF fcarney

          Gahhhh! It looks like I should be using a TextArea now:
          https://doc.qt.io/archives/qt-5.11/qml-qtquick-controls2-textarea.html

          T Offline
          T Offline
          Tom_H
          wrote on last edited by
          #4

          @fcarney Yes, this came up recently:

          https://forum.qt.io/topic/106020

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved