rawfool
3rd June 2013, 14:45
I'm using a QTableWidget, but I'm looking for a way to dynamically resize the columns to fit the widget base width.
I tried this, but it's resizing the column contents only to fit it's column. But I need the columns resize itself to the widget's width.
for(int nCol, nRow = 0; nRow < 3; nRow++)
{
for(nCol = 0; nCol < 4; nCol++)
{
vulnTable->setItem(nRow, nCol, new QTableWidgetItem(QString::number(nRow) + " " + QString::number(nCol)));
vulnTable->resizeRowsToContents();
vulnTable->resizeColumnsToContents();
}
}
And the result is as shown in the pic. How do I avoid the gap left-out?
9097
Thank you.
I tried this, but it's resizing the column contents only to fit it's column. But I need the columns resize itself to the widget's width.
for(int nCol, nRow = 0; nRow < 3; nRow++)
{
for(nCol = 0; nCol < 4; nCol++)
{
vulnTable->setItem(nRow, nCol, new QTableWidgetItem(QString::number(nRow) + " " + QString::number(nCol)));
vulnTable->resizeRowsToContents();
vulnTable->resizeColumnsToContents();
}
}
And the result is as shown in the pic. How do I avoid the gap left-out?
9097
Thank you.