通过调用QTtableView的verticalHeader()->setDefaultSectionSize(15)可以设置tableview所有行的默认行高。
1: 使用QTableView自己带的函数,函数原型如下:
ui.tableWidget->resizeColumnToContents (0);
将第一列根据内容自动调整列宽。
| 根据内容自动调整某列的列宽 void QTableView::resizeColumnToContents ( int column ) [slot] Resizes the given column based on the size hints of the delegate used to render each item in the column.
Resizes all columns based on the size hints of the delegate used to render each item in the columns. |
| 根据内容自动调整某一行的行高 void QTableView::resizeRowToContents ( int row ) [slot] Resizes the given row based on the size hints of the delegate used to render each item in the row.
根据内容自动调整所有行的行高。 Resizes all rows based on the size hints of the delegate used to render each item in the rows. |
本文介绍了如何使用 Qt 的 QTableView 控件来自动调整表格视图中列宽和行高的方法。具体包括设置所有行的默认高度、根据内容自动调整单列或多列的宽度以及单行或多行的高度。
1306

被折叠的 条评论
为什么被折叠?



