Reputation: 111
How to stretch the last column of a TableView in qml?
In C++ with Qt framework it is possible to use setStretchLastSection from QHeaderView but is there a way to do it in qml?
EDIT: To be more specific: On the screenshot below, I want the three column to fill the entire width of the TableView, in order to get rid that "ghost" 4th column.
Edit2:
I wanted to do something like that:
TableView{
model: ListModel{
ListElement {
name: "Apple"
cost: 2.45
}
ListElement {
name: "Orange"
cost: 3.25
}
ListElement {
name: "Banana"
cost: 1.95
}
}
TableViewColumn{
role: "name"
title: "Name"
}
TableViewColumn{
role: "cost"
title: "Cost"
}
Component.onCompleted: stretchLastSection /*<-----/*
}
But the way to do it for now seems to be by calculating the width of TableViewColumn as @folibis said.
Some related topic with QtDesigner and Qt framework:
QTableView / QTableWidget: Stretch Last Column using Qt Designer
Qt table last column not stretching to fill in parent
How to stretch QTableView last column header
Upvotes: 1
Views: 528