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 with empty TextArea
Forum Updated to NodeBB v4.3 + New Features

ScrollView with empty TextArea

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 629 Views 2 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.
  • F Offline
    F Offline
    flo_g
    wrote on last edited by
    #1

    Hi everyone!
    I am new to the QTForum and also pretty new to QML and QT Quick in general.

    At the moment, I am working on my very first project which is a lot of fun but I encounter difficulties from time to time. Right now, I have two problems:

    (1) the minor one: how can I activate mouse-click selection in the TextArea?

    (2) the major problem:
    I nested the TextArea inside a ScrollView to ensure scrolling whenever the text gets too long for the window. But since I want the user to enter text in the TextArea, the TextArea has to be empty at the start. That means that with the ScrollView one cannot click inside the TextArea and edit it.

    Here is the part of the code:

            ScrollView {
                id: view
                anchors.fill: parent
                anchors.bottomMargin: 40
    
                TextArea {
                    id: journalEntry
                    width: 80
                    height: 20
                    color: "#f2f2f2"
                    placeholderText: "Type your journal entry here"
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.top: parent.top
                    anchors.bottom: parent.bottom
                    anchors.fill: parent
                    font.pixelSize: 20
                    wrapMode: Text.WordWrap
                    font.bold: true
                    font.family: "Courier"
                    selectionColor: "#c55af2"
                    anchors.rightMargin: 20
                    anchors.leftMargin: 20
                    anchors.bottomMargin: 30
                    anchors.topMargin: 20
                    onTextChanged: if(text != "") return animationListExpand.running = true; else return animationListRetract.running = true
                    ScrollBar.vertical: ScrollBar { }
                    focus: true
                }
            }
    

    I hope you have a quick solution to this.

    Thank you very much and all the best,
    flo

    ODБOïO 1 Reply Last reply
    0
    • F flo_g

      Hi everyone!
      I am new to the QTForum and also pretty new to QML and QT Quick in general.

      At the moment, I am working on my very first project which is a lot of fun but I encounter difficulties from time to time. Right now, I have two problems:

      (1) the minor one: how can I activate mouse-click selection in the TextArea?

      (2) the major problem:
      I nested the TextArea inside a ScrollView to ensure scrolling whenever the text gets too long for the window. But since I want the user to enter text in the TextArea, the TextArea has to be empty at the start. That means that with the ScrollView one cannot click inside the TextArea and edit it.

      Here is the part of the code:

              ScrollView {
                  id: view
                  anchors.fill: parent
                  anchors.bottomMargin: 40
      
                  TextArea {
                      id: journalEntry
                      width: 80
                      height: 20
                      color: "#f2f2f2"
                      placeholderText: "Type your journal entry here"
                      anchors.left: parent.left
                      anchors.right: parent.right
                      anchors.top: parent.top
                      anchors.bottom: parent.bottom
                      anchors.fill: parent
                      font.pixelSize: 20
                      wrapMode: Text.WordWrap
                      font.bold: true
                      font.family: "Courier"
                      selectionColor: "#c55af2"
                      anchors.rightMargin: 20
                      anchors.leftMargin: 20
                      anchors.bottomMargin: 30
                      anchors.topMargin: 20
                      onTextChanged: if(text != "") return animationListExpand.running = true; else return animationListRetract.running = true
                      ScrollBar.vertical: ScrollBar { }
                      focus: true
                  }
              }
      

      I hope you have a quick solution to this.

      Thank you very much and all the best,
      flo

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      hi @flo_g said in ScrollView with empty TextArea:

      (1) the minor one: how can I activate mouse-click selection in the TextArea?

      set selectByMouse property to true

      @flo_g said in ScrollView with empty TextArea:

      (2) the major problem:

      remove the line anchors.fill: parent in your TextArea,
      your are using width/height plus anchors.Top/Bottom/left/right plus anchors.fill to set the size of the TextArea, it is redundant, you do 3 times the same thing, do just one

      1 Reply Last reply
      1
      • F Offline
        F Offline
        flo_g
        wrote on last edited by
        #3

        @LeLev Thank you very much! This worked flawlessly!

        1 Reply Last reply
        0

        • Login

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