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 5.12 TableView columnt width depending on content?
Forum Updated to NodeBB v4.3 + New Features

qml 5.12 TableView columnt width depending on content?

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

    Hi!
    I'm wondering, is there any way to adopt width of the columnt to the content?
    I got so far, that

    TableView {
                id: table
                Layout.alignment: Qt.AlignCenter
                Layout.preferredWidth : 800
                Layout.preferredHeight: 300
                columnWidthProvider: function (column) { return 100 }
                rowHeightProvider  : function (row)    { return 100 }
                clip: true
                model: StandardModel {}
    
                delegate: Rectangle {
                    border.color: "blue"
                    border.width: 1
                    color: (heading==true) ? "red" : "green"
                    Text {
                        id: text
                        text: tabledata
                        font.pointSize: 12
                        anchors.centerIn: parent
                    }                
                }
    

    Suppose, that i could calc width of the Text (there is a function named contentWidth ). Should i try to iterate over rows in columnWidthProvider to calc the maximum value of the cells in the column and returnin this? (i dont get how to iterate over rows in column)

    Here is an example of my table (but its obvious that columns should be different width which known only runtime)
    0_1557315395977_table.PNG

    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