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. Sizing a TableView to its content
Forum Updated to NodeBB v4.3 + New Features

Sizing a TableView to its content

Scheduled Pinned Locked Moved QML and Qt Quick
qmltableviewchildrenrectcontentheight
1 Posts 1 Posters 688 Views 1 Watching
  • 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.
  • qwasder85Q Offline
    qwasder85Q Offline
    qwasder85
    wrote on last edited by qwasder85
    #1

    Hi all,
    I'm trying to create a TableView that will always show all rows without the need for a scrollbar.

    TableView
    {
        id: compareTableView
    
        width: parent.width
        height: childrenRect.height
    
        model: myModel
        alternatingRowColors: true
        selectionMode: SelectionMode.NoSelection
        headerVisible: false
        frameVisible: false
        verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
        flickableItem.interactive: false
        clip: true
    
        rowDelegate: Rectangle { height: 20 }
    
        TableViewColumn { ... }
        TableViewColumn { ... }
        TableViewColumn { ... }
    }
    

    I tried to set the height of the TableView to childrenRect.height, which resulted in the TableView not being visible at all.
    Okay, so the size of the childrenRect isn't available at that time. So I tried to set the same in a Component.onCompleted-block. Now I do see the table, but it is only ~200 px high, which seems to be some sort of default height, since it is the same height I get when I omit a height alltogether.
    Then I thought: Maybe the 200 px height comes from the height of my rowDelegate multiplied by the rowCount. I changed its height to 50, but still got the same TableView height in return.

    Now I'm out of ideas, can anyone help me?

    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