Hello,

I'm trying to learn how to use TableView. I've tried an example from Qt
docs and this is what I'm getting for now:

[image: image.png]
HorizontalHeaderView does not take columns' width into account. I'm pretty
sure it should be able to do this and tell its TableView to adjust its
column width accordingly. Am I doing something wrong?

The code is below:

ColumnLayout
    {
        anchors.fill: parent

        HorizontalHeaderView {
            id: horizontalHeader
            model: ["checked 0000000000", "amount 0000000000", "fruit type
0000000000", "fruit name 0000000000", "fruit price 0000000000"]
            syncView: tableView
            clip: true
        }

        TableView {
            id: tableView

            columnSpacing: 1
            rowSpacing: 1
            boundsBehavior: Flickable.StopAtBounds
            clip: true

            Layout.fillHeight: true
            Layout.fillWidth: true

            model: TableModel {
                TableModelColumn { display: "checked" }
                TableModelColumn { display: "amount" }
                TableModelColumn { display: "fruitType" }
                TableModelColumn { display: "fruitName" }
                TableModelColumn { display: "fruitPrice" }

                rows: [
                    {
                        checked: false,
                        amount: 1,
                        fruitType: "Apple",
                        fruitName: "Granny Smith",
                        fruitPrice: 1.50
                    },
                    {
                        checked: true,
                        amount: 4,
                        fruitType: "Orange",
                        fruitName: "Navel",
                        fruitPrice: 2.50
                    },
                    {
                        checked: false,
                        amount: 1,
                        fruitType: "Banana",
                        fruitName: "Cavendish",
                        fruitPrice: 3.50
                    }
                ]
            }
            delegate:  Label {
                text: model.display
                padding: 12
            }
        }
    }
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to