I am using QStandardItemModel
inside QTableView
. Here i have two button & Qtableview
inside my mainwindow.
I need only 4 columns inside this. And rows will vary. The two Buttons will be used to add/delete a row (test case).
setHorizontalHeaderItem
is not showing all the text(means all text is not visible). Example if i put'Text for the Employee Name'
it is not fully visible ?- How to make
QStandardItemModel
occupy fullQTableview
(width
). At present it is showing at top left corner ?
How to achieve it?
Code :
model= new QStandardItemModel(4, 4);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
model->setItem(row, column, item);
}
}
model->setHorizontalHeaderItem(0, new QStandardItem(tr("Time")));
model->setHorizontalHeaderItem(1, new QStandardItem(tr("Text for the Employee Name")));
model->setHorizontalHeaderItem(2, new QStandardItem(tr("Text for the Employee Address")));
model->setHorizontalHeaderItem(3, new QStandardItem(tr("Text for the Employee Date of Birth")));
model->setVerticalHeaderItem(0, new QStandardItem(tr("Test-Case-----1")));