gpt4 book ai didi

QTableWidget 自动拉伸(stretch)最后一个字段,就像 QTreeWidget 一样

转载 作者:行者123 更新时间:2023-12-04 13:01:38 24 4
gpt4 key购买 nike

有没有让 QTableWidget 的标题项像 QTreeWidget 一样拉伸(stretch)到全尺寸?

最佳答案

来自 QTableView 文档:

By default, the cells in a table do not expand to fill the available space.

You can make the cells fill the available space by stretching the last header section. Access the relevant header using horizontalHeader() or verticalHeader() and set the header's stretchLastSection property.


你应该试一试。
 QTableWidget *tw = ...;
tw->horizontalHeader()->setStretchLastSection(true);
stretchLastSection文档有:

Note: The horizontal headers provided by QTreeView are configured with this property set to true, ensuring that the view does not waste any of the space assigned to it for its header.


这就是 TreeView 的做法。

关于QTableWidget 自动拉伸(stretch)最后一个字段,就像 QTreeWidget 一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10764761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com