Cannot resize a QTableView widget inside an another window
-
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 QTableView does 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.
@void MyApp::showTabulatedEvents() {
const int maxRows = dbStoreToday.size();upcomingEventsForToday(); // ustaw liste dbStoreToday
QWidget* tableWindow = new QWidget;
QVBoxLayout* tableLay = new QVBoxLayout(tableWindow);
tableWindow->setWindowTitle(trUtf8("Upcoming events for today"));
QTableView* tableView = new QTableView;
tableLay->addWidget(tableView);
tableView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);QStandardItemModel* model = new QStandardItemModel(5,dbStoreToday.size());
for(int row = 0; row < maxRows; ++row) {
model->setItem(row,0,new QStandardItem(dbStoreToday[row].imie));
model->setItem(row,1,new QStandardItem(dbStoreToday[row].nazwisko));
model->setItem(row,2,new QStandardItem(dbStoreToday[row].nazwa_wyd));
model->setItem(row,3,new QStandardItem(dbStoreToday[row].data_wyd.toString()));
model->setItem(row,4,new QStandardItem(tr("%1").arg(dbStoreToday[row].przypomnienie)));
}
tableView->setModel(model);
tableView->show();
tableWindow->show();
}@This is the window shape I can see when I show the QTableView
!http://zebik.republika.pl/tableView.jpg(Table View)!