Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

resizeColumnsToContents has no effect in my tableView...



  • Hello,
    Using QT 5.10.1 I'm trying to use resizeColumnsToContents() but nothing happened...
    What I'm doing wrong?...

    thanks a lot for your help!!

    here my code:

                TableView {
                    id:listView
                    width: parent.width
                    height: parent.height
                    onRowCountChanged:listModel.resizeColumnsToContents()
                    model: ListModel {
                        id: listModel
                        Component.onCompleted: {
                            JS.dbpart(stringVariable, stringVariable2)
                            listView.resizeColumnsToContents()
                        }
                    }
                    TableViewColumn {
                        role: "description"
                        title: "Description"
                        width:100
                    }
                    TableViewColumn {
                        role: "task"
                        title: "Operation"
                        //width:150
                    }
                    TableViewColumn {
                        role: "part"
                        title: "Part Number"
                        visible: stringVariable2 === "05" ? false : true
                        //width:200
                    }
                    TableViewColumn {
                        role: "serial"
                        title: "Serial Number"
                        visible: stringVariable2 === "05" ? false : true
                        //width:175
                    }
    }
    

Log in to reply