Search code examples
qtqmlstylesheet

TextArea styles in QML


I want to change the color of my TextArea object but I don't know how property can do it.

I've tried with

TextArea {
    styles: TextAreaStyle {
        borderColor : "green"
    }
}

or

TextArea {
    TextArea.border.color : "green"
}

But both examples doesn't work. I can't found a single property of TextArea for change the border color in the QML reference. Is this possible?, and how can I do it?

Thanks!


Solution

  • As I said there is no borderColor in TextAreaStyle. But you can do it in "tricky" way:

    Rectangle {
        color: "green"
        anchors.fill: parent
        anchors.margins: 20
    
        TextArea {
            anchors.fill: parent
            anchors.margins: 1
            style: TextAreaStyle {
                backgroundColor : "yellow"
            }
    
        }
    }