Hi folks,

I'm adding a QTableView into a QVBoxLayout on top of a QPushButton, as follows:

Qt Code:
  1. QVBoxLayout* mainLayout = new QVBoxLayout;
  2.  
  3. QPushButton* btn_OK = new QPushButton(tr("OK"));
  4. connect(btn_OK, SIGNAL(clicked()), this, SLOT(accept()));
  5.  
  6. model = NULL;
  7. loadModel ();
  8.  
  9. tableView = new QTableView(this);
  10. tableView->setModel (model);
  11. tableView->verticalHeader()->hide();
  12. tableView->horizontalHeader()->setStretchLastSection (true);
  13. tableView->setSelectionMode (QAbstractItemView::SingleSelection);
  14. tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
  15.  
  16. mainLayout->addWidget(tableView);
  17. mainLayout->addWidget(btn_OK);
  18.  
  19. setLayout (mainLayout);
To copy to clipboard, switch view to plain text mode 

This displays everything, but the dialog's initial size is too narrow and the QTableView uses a horizontal scroll bar. I would like to:
-initially size the dialog so that all the columns are shown without the need to scroll
-prevent the user from resizing the dialog smaller than this size

I have tried setting size policies on the QTableView and the Dialog, turning off the scroll bar, etc. but am not having any luck. Do I need to reimplement sizeHint() for the dialog? Any ideas would be really appreciated.

Russ