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. QML: Dynamic resizing main window based on item appended to listmodel
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 899 Views
  • 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.
  • A Offline
    A Offline
    AexAcad
    wrote on last edited by
    #1

    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:

    Main.qml: 
    
    ApplicationWindow {
        id: root
        width: 450
        minimumHeight: 75
        visible: true
        color: "#373131"
    
    SwipeView {
    id: swipev
    
    Page{
                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.

    ConvoView.qml
    
    Item {
        id: item1
        property alias inmsg: conversationList
    
     ListModel{
        id: conversationList
        }
    
     ListView{
    ... 
    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.

    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