I've got a QTableView containing a QStandardItemModel which gives a table of 2 columns, 4 rows, with both horizontal and vertical headers on each (so a 3x5 grid). I've put this QTableView inside a QGroupBox which is part of the main QGridLayout.

I'd like the table to appear with all the cells with no scrollbars and no blank space, but I can't achieve it. I'm managed to remove the blank space down the right-hand side using table->horizontalHeader()->setResizeMode(QHeaderView::Stretch), but can't find an equivalent to remove the vertical scroll bar and/or the empty space at the bottom.

Here's a snippet of the code:
Qt Code:
  1. QGroupBox *Window::SetLineTableLayout()
  2. {
  3. line_model = new QStandardItemModel(4, 2, this);
  4. line_model->setHeaderData(0, Qt::Horizontal, tr("Start"));
  5. line_model->setHeaderData(1, Qt::Horizontal, tr("End"));
  6. line_model->setHeaderData(0, Qt::Vertical, tr("Index"));
  7. line_model->setHeaderData(1, Qt::Vertical, tr("X"));
  8. line_model->setHeaderData(2, Qt::Vertical, tr("Y"));
  9. line_model->setHeaderData(3, Qt::Vertical, tr("Z"));
  10. // line_model has values placed in it elsewhere.
  11.  
  12. QTableView *table = new QTableView;
  13.  
  14. table->setModel(line_model);
  15.  
  16. QItemSelectionModel *selectionModel = new QItemSelectionModel(line_model);
  17. table->setSelectionModel(selectionModel);
  18. table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
  19.  
  20. QGroupBox *line_box = new QGroupBox(tr("Selected Line"));
  21. QVBoxLayout *layout = new QVBoxLayout();
  22. layout->addWidget(table);
  23. line_box->setLayout(layout);
  24.  
  25. return line_box;
  26. }
To copy to clipboard, switch view to plain text mode 

which is called from (editted version):
Qt Code:
  1. QGridLayout *mainLayout = new QGridLayout;
  2.  
  3. QGroupBox *line_box = new QGroupBox;
  4. line_box = SetLineTableLayout();
  5.  
  6. mainLayout->addWidget(line_box, 1, 1, 1, 1);
  7. // Lots of other widgets added to the grid not shown here for clarity.
  8.  
  9. setLayout(mainLayout);
To copy to clipboard, switch view to plain text mode 

Any clues will be welcome.