[Interest] HorizontalHeaderView is not able to calculate its items' width?
Alexander Dyagilev
alervdvcw at gmail.com
Sat Mar 23 11:11:41 CET 2024
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
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240323/89520fac/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 16745 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240323/89520fac/attachment.png>
More information about the Interest
mailing list