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. set cell width to content width in TableView
Forum Updated to NodeBB v4.3 + New Features

set cell width to content width in TableView

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

    Hi, Here is the following code :

    import QtQuick 2.14
    import QtQuick.Controls 2.14
    
    TableView {
      id: root
      property var base
      height: 50 * rows
      width: base.width
      clip: true
      columnSpacing: 1
      rowSpacing: 1
      delegate: Rectangle {
            implicitWidth: textinput.contentWidth + 10
            implicitHeight: textinput.contentHeight + 10
            TextInput {
                anchors.fill: parent
                id: textinput
                text: display
                onTextChanged: {forceLayout()}
            }
        }
    }
    

    I have the following warning : TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!

    If I use onTextEdited instead of onTextChanged no warning but after initial load, colomn width is not well adjusted. It's fixed after I edit one cell.

    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