当前位置: 代码迷 >> QT开发 >> QTableWidget在保证表格充满窗口时,setRowHeight不起作用是咋回事
  详细解决方案

QTableWidget在保证表格充满窗口时,setRowHeight不起作用是咋回事

热度:220   发布时间:2016-04-25 03:08:35.0
QTableWidget在保证表格充满窗口时,setRowHeight不起作用是怎么回事
#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

如果行多的话是起作用的
  相关解决方案