I have a QTableView where all rows have exactly the same height and I'd like to make the QTableView the exact height to fit a specific number of rows. Right now I'm using code like this to calculate the height needed:

QTableView *pTableView; // The tableview whose model is filled with data.
const int nNumRows = 10;
int nRowHeight = pTableView->rowHeight(0);
int nTableHeight =
(nNumRows * nRowHeight) +
pTableView->horizontalHeader()->height() +
2 * pTableView->frameWidth();
pTableView->setMinimumHeight(nTableHeight);
pTableView->setMaximumHeight(nTableHeight);

However, the height of the table still seems to be about 2 pixels shorter than what the rows need. Any idea what I might be missing?

Thanks!