Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QML TextArea won't scroll

I added a simple TextArea in my application. Unfortunately, I can't scroll through the text even if its contentHeight bypasses its height.
Here is the code:

import QtQuick 2.7
import QtQuick.Controls 2.0

ApplicationWindow {
    id: appWindow
    visible: true
    width: 480
    height: 640
    TextArea{
        anchors.fill: parent
        anchors.margins: 100
        wrapMode: TextEdit.Wrap
        Component.onCompleted: {
            console.log("width:", width)
            console.log("contentWidth:", contentWidth)
            console.log("height:", height)
            console.log("contentHeight:", contentHeight)
        }
        onTextChanged: {
            console.log("width:", width)
            console.log("contentWidth:", contentWidth)
            console.log("height:", height)
            console.log("contentHeight:", contentHeight)
        }
    }
}
like image 532
Akash Agarwal Avatar asked Sep 17 '25 10:09

Akash Agarwal


1 Answers

TextArea is not scrollable by default, mainly to make it possible to have multi-line editors as part of a scrollable page without having nested Flickables, which often gives sub-optimal experience. In order to make a standalone TextArea scrollable, you can attach it to a Flickable as illustrated in the documentation.

like image 180
jpnurmi Avatar answered Sep 19 '25 08:09

jpnurmi