QML Word wrap и TextArea и поля - PullRequest
0 голосов
/ 15 мая 2019

Как сделать так, чтобы мое слово TextArea обернуло текстовую область и автоматически отрегулировало ее высоту, чтобы отобразить доступный текст в TextArea? Во-вторых, как я могу удалить нечетное расстояние, которое видно на моем изображении.

Вот что у меня сейчас:

enter image description here

Вот чего я хочу:

enter image description here

Код QML:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3

Frame {
    anchors.centerIn: parent
    anchors.fill: parent

    ListView {
        implicitWidth: parent.width
        implicitHeight: parent.height
        clip: true

        model: ListModel {
            ListElement {
                description: "Wash the car this could be a really long message with some multiline support we will see how it works."
            }
            ListElement {
                description: "Fix the car"
            }
            ListElement {
                description: "Sell the car"
            }
            ListElement {
                description: "Wash the car this could be a really long message with some multiline support we will see how it works. This should word wrap quite a lot of times."
            }
            ListElement {
                description: "Fix the car"
            }
            ListElement {
                description: "Sell the car"
            }
            ListElement {
                description: "Wash the car"
            }
            ListElement {
                description: "Fix the car"
            }
            ListElement {
                description: "Sell the car"
            }
        }

        delegate: RowLayout {
            Layout.fillWidth: true

            Rectangle {
                id: newsicon
                width: 16
                height: 16
                color: "steelblue"
                Layout.alignment: Qt.AlignTop
            }

            ColumnLayout {
                Layout.fillWidth: true
                spacing: 0

                TextArea {
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignTop
                    id: messageText
                    text: model.description
                    wrapMode: TextEdit.WordWrap
                    readOnly: true
                    textMargin: 0.0
                    background: null
                }
                Label {
                    id: dateText
                    text: "Dec 20, 2019"
                    font.italic: true
                    font.pointSize: 8
                    color: "grey"
                }
            }
        }

        ScrollBar.vertical: ScrollBar {
            active: true
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...