Hi,

I've got quite annoying problem. I've put a QTableView in a QWidget that works as an another window. The problem is that QTableViewdoes not resize itself when I resize a window. Also, the window starts with its minimum geometry as if there was none of any layouts at all even though the QTableView is inside. So far, I tried to put QTableView in the one of the layouts: QGridLayout, QHBoxLayout etc. but it does not solve the problem. Am I doing something wrong here? I did not have such a problem before; all layouts with widgets worked great for me.

Just in case I put the part of the code that is responsible for opening the window.

Qt Code:
  1. void MyApp::showTabulatedEvents() {
  2. const int maxRows = dbStoreToday.size();
  3.  
  4. upcomingEventsForToday(); // ustaw liste dbStoreToday
  5.  
  6. QWidget* tableWindow = new QWidget;
  7. QVBoxLayout* tableLay = new QVBoxLayout(tableWindow);
  8. tableWindow->setWindowTitle(trUtf8("Upcoming events for today"));
  9. QTableView* tableView = new QTableView;
  10. tableLay->addWidget(tableView);
  11. tableView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
  12.  
  13. QStandardItemModel* model = new QStandardItemModel(5,dbStoreToday.size());
  14. for(int row = 0; row < maxRows; ++row) {
  15. model->setItem(row,0,new QStandardItem(dbStoreToday[row].imie));
  16. model->setItem(row,1,new QStandardItem(dbStoreToday[row].nazwisko));
  17. model->setItem(row,2,new QStandardItem(dbStoreToday[row].nazwa_wyd));
  18. model->setItem(row,3,new QStandardItem(dbStoreToday[row].data_wyd.toString()));
  19. model->setItem(row,4,new QStandardItem(tr("%1").arg(dbStoreToday[row].przypomnienie)));
  20. }
  21. tableView->setModel(model);
  22. tableView->show();
  23. tableWindow->show();
  24. }
To copy to clipboard, switch view to plain text mode 

tableView.jpg