QML: Dynamic resizing main window based on item appended to listmodel

  • Hi, I am working on a chat based application where I am trying to resize / grow the height of the main window when text is appended to the listmodel based on the message box height.

    The listmodel is in a seperate file to which I am appending through input from textfield and property alias. The main.qml where the listmodel qml is displayed:

    ApplicationWindow {
        id: root
        width: 450
        minimumHeight: 75
        visible: true
        color: "#373131"
    SwipeView {
    id: swipev
                id: page1
    Rectangle {
                    id: rectangle2
                    color: "#272131"
                    anchors.left: parent.left
                    anchors.leftMargin: 0
                    anchors.bottom: parent.bottom
                    anchors.bottomMargin: 0
                    anchors.top: parent.top
                    anchors.topMargin: 0
                    anchors.right: rectangle3.left
                    anchors.rightMargin: 0
                    ConvoView { id: conview
                        anchors.right: rectangle2.right

    Listmodel and Listview where the appended text is added to the messagerow.

    Item {
        id: item1
        property alias inmsg: conversationList
        id: conversationList
    delegate: Column {
                            spacing: 6
                            anchors.right: parent.right
                            Row {
                                id: messageRow
                                spacing: 6
                                Rectangle {
                                    width: messageText.implicitWidth + 24
                                    height: messageText.implicitHeight + 24
                                    color: "lightgrey"
                                    Label {
                                        id: messageText
                                        text: model.InputQuery
                                        color: "black"
                                        anchors.fill: parent
                                        anchors.margins: 12
                                        wrapMode: Label.Wrap

    How can I set the height of the window to grow as the messages appended increases? I know i can set a fixed height and use a scrollbar but that's what I want to avoid. Is there any documentation i can find about dynamic resizing or resources/examples i can refer too ? Please help.

Log in to reply