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. How to enable to scrolling Rectangle which contains text?
Forum Updated to NodeBB v4.3 + New Features

How to enable to scrolling Rectangle which contains text?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 393 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.
  • M Offline
    M Offline
    moon9yu
    wrote on last edited by
    #1

    Hi, I want to scroll rectangle's text like terminal.
    But the problem is it doesn't scrollable...
    fbbe2090-fff8-45d2-adc6-5ffdd3fd7b8b-image.png
    This is my part of qml file.

    Window {
        id: mainWindow
        width: 640
        height: 480
        visible: true
        title: qsTr("SOME/IP Simulator")
    
        RowLayout {
            property string someipLog
            id: mainRow
            anchors.fill: parent
            spacing: 10
    
            Rectangle {
                id: consoleItem
                Layout.fillHeight: parent.height
                Layout.minimumHeight: mainWindow.height
                Layout.minimumWidth: mainWindow.width / 3 * 2
                color: "black"
                clip: true
                Text {
                    id: logArea
                    anchors.fill: parent
                    text: simulator.someipLog // text from c++ class
                    wrapMode: Text.WrapAnywhere
                    color: "white"
                    font.pointSize: 13
                    font.weight: Font.Medium
                }
                ScrollBar {
                    hoverEnabled: true
                    active: hovered || pressed
                    orientation: Qt.Vertical
                    size: consoleItem.height / logArea.height
                    anchors.top: parent.top
                    anchors.right: parent.right
                    anchors.bottom: parent.bottom
                }
            }
    
            Items ...
        }
    }
    
    B 1 Reply Last reply
    0
    • M moon9yu

      Hi, I want to scroll rectangle's text like terminal.
      But the problem is it doesn't scrollable...
      fbbe2090-fff8-45d2-adc6-5ffdd3fd7b8b-image.png
      This is my part of qml file.

      Window {
          id: mainWindow
          width: 640
          height: 480
          visible: true
          title: qsTr("SOME/IP Simulator")
      
          RowLayout {
              property string someipLog
              id: mainRow
              anchors.fill: parent
              spacing: 10
      
              Rectangle {
                  id: consoleItem
                  Layout.fillHeight: parent.height
                  Layout.minimumHeight: mainWindow.height
                  Layout.minimumWidth: mainWindow.width / 3 * 2
                  color: "black"
                  clip: true
                  Text {
                      id: logArea
                      anchors.fill: parent
                      text: simulator.someipLog // text from c++ class
                      wrapMode: Text.WrapAnywhere
                      color: "white"
                      font.pointSize: 13
                      font.weight: Font.Medium
                  }
                  ScrollBar {
                      hoverEnabled: true
                      active: hovered || pressed
                      orientation: Qt.Vertical
                      size: consoleItem.height / logArea.height
                      anchors.top: parent.top
                      anchors.right: parent.right
                      anchors.bottom: parent.bottom
                  }
              }
      
              Items ...
          }
      }
      
      B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      @moon9yu There is nothing to connect your scrollbar to the text rectangle. Have you tried ScrollView? That would do most of your work for you.

      M 1 Reply Last reply
      0
      • B Bob64

        @moon9yu There is nothing to connect your scrollbar to the text rectangle. Have you tried ScrollView? That would do most of your work for you.

        M Offline
        M Offline
        moon9yu
        wrote on last edited by
        #3

        @Bob64 Thank you for replying. I solved my problem using flickable.

        Rectangle {
                    id: consoleItem
                    Layout.fillHeight: parent.height
                    Layout.minimumHeight: mainWindow.height
                    Layout.minimumWidth: mainWindow.width / 3 * 2
                    color: "black"
                    Flickable {
                        id: flickable
                        contentHeight: logArea.implicitHeight
                        contentWidth: logArea.implicitWidth
                        contentY: contentHeight - height
                        boundsMovement: Flickable.StopAtBounds
                        anchors.fill: parent
                        clip: true
                        Text {
                            id: logArea
                            text: simulator.someipLog
                            color: "white"
                            font.pointSize: 13
                            font.weight: Font.Medium
                            padding: 10
                        }
                        ScrollBar.vertical: ScrollBar {
                            id: vbar
                            active: hovered || pressed
                            orientation: Qt.Vertical
                            parent: flickable.parent
                            anchors.top: flickable.top
                            anchors.right: flickable.right
                            anchors.bottom: flickable.bottom
                        }
                        ScrollBar.horizontal: ScrollBar {
                            id: hbar
                            active: hovered || pressed
                            orientation: Qt.Horizontal
                            parent: flickable.parent
                            anchors.left: flickable.left
                            anchors.right: flickable.right
                            anchors.bottom: flickable.bottom
                        }
                    }
                }
        

        71a9ebe7-9319-4b0e-adbe-7259c9f99d20-image.png

        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