[Interest] HorizontalHeaderView is not able to calculate its items' width?

Alexander Dyagilev alervdvcw at gmail.com
Sat Mar 23 11:42:16 CET 2024


I've created a bug report with more details here:
https://bugreports.qt.io/browse/QTBUG-123639

On Sat, Mar 23, 2024 at 5:32 PM Alexander Dyagilev <alervdvcw at gmail.com>
wrote:

> Ohh... I was able to fix this issue. It's required:
> 1) Remove *syncView: tableView* line
> 2) Add *syncView: horizontalHeader* line to TableView's properties.
>
> So, as far as I understand, it can't sync in the both directions, and
> syncView property must be set to an object with the lower expected
> dimensions (which is not very good and is not acceptable in all cases).
>
> On Sat, Mar 23, 2024 at 5:11 PM Alexander Dyagilev <alervdvcw at gmail.com>
> wrote:
>
>> 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/2d8d09ba/attachment-0001.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/2d8d09ba/attachment-0001.png>


More information about the Interest mailing list