Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to dynamicly change rows height in QTableView in QML

How to dynamicly change rows height in QTableView in QML

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtableviewqmlrowdelegate
1 Posts 1 Posters 775 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.
  • R Offline
    R Offline
    RostV
    wrote on last edited by
    #1

    Hi, I have a table of 4 columns, in one of which is text. When you change the width of the column, the width of the internal text also changes. In some cases, the width of the text becomes rather small and the text begins to increase its height (text wrap). How can I increase the height of the row in which this text is located?

    This is a column with text

    TableViewColumn {
                    id: fullNameColumn
                    property int minColWidth: 175
                    property int maxColWidth: 500
                    role: "fullName"
                    title: "ФИО"
                    width: 360
                    property string imageSource : ""
                    onWidthChanged: {
                       if (width < minColWidth)
                           width = minColWidth
                    }
    
                    delegate: Rectangle{
                        id: rowCellContentFullName
                        color: "transparent"
                        Text {
                            property int maxColWidth: 400
                            id: labelFullName
                            objectName: "labelFullName"
                            font.pixelSize: 13
                            wrapMode: Text.Wrap
                            anchors.leftMargin: 38
                            anchors.left: parent.left
                            horizontalAlignment: styleData.textAlignment
                            anchors.verticalCenter: parent.verticalCenter
                            visible: parent.visible
                            width: parent.width - this.anchors.leftMargin * 2
                            text: styleData.value !== undefined ? styleData.value : ""
                            color: "#474747"
                            renderType: Text.NativeRendering     
                    }
                }
    

    This is the rowDelegate

                property Component rowDelegate: Rectangle {
                        id: rowDel
                        objectName: "RowDelegate"
                        height: parent.parent.children[1].children[2].children[0].children[0].height < 50 ? 50 : parent.parent.children[1].children[2].children[0].children[0].height
                        property color selectedColor: styleData.hasActiveFocus ? primaryColor : secondaryColor
                        property bool selectionMaskVisible
                        property bool selected: false
                }
    

    In rowDelegate Im binding height with terrible expression, but it works. Works only for column 3 (where FullName). If i drag this column in another space my code doesnt work.

    Can i change rows height in QTableView QML without this terrible expressions? Mb You know some way to solve this problem?

    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