#include <QApplication>
#include <QTableWidget>
#include <QHeaderView>
#include <QDebug>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
TableWidget tw;
tw.horizontalHeader()->setStretchLastSection(true);
tw.verticalHeader()->setStretchLastSection(true);
tw.setRowCount(1);
tw.setColumnCount(3);
tw.setRowHeight(0, 20);//该语句不起作用,无法调整为20
tw.show();
qDebug() << tw.rowHeight(0);
return app.exec();
}
该段代码中,tw.setRowHeight(0, 20);没有起作用,如何能让它起作用,并且保证表格充满整个窗口
------解决思路----------------------
tw.verticalHeader()->setStretchLastSection(true);
把最后一行拉伸了
tw.setRowCount(1);
只有一行数据
tw.setRowHeight(0, 20);//该语句不起作用,无法调整为20
如果行多的话是起作用的