A rough solution
{
public:
explicit TableWidget
(QWidget * parent
= 0) {
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
horizontalHeader()->setStretchLastSection(true);
}
TableWidget
(int rows,
int columns,
QWidget *parent
= 0) {
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
horizontalHeader()->setStretchLastSection(true);
}
protected:
{
if(model() and model()->columnCount())
for(int column = 0; column < model()->columnCount(); column++)
setColumnWidth(column, event->size().width() / model()->columnCount());
}
};
class TableWidget : public QTableWidget
{
public:
explicit TableWidget(QWidget * parent = 0)
: QTableWidget(parent)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
horizontalHeader()->setStretchLastSection(true);
}
TableWidget(int rows, int columns, QWidget *parent = 0)
: QTableWidget(rows, columns, parent)
{
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
horizontalHeader()->setStretchLastSection(true);
}
protected:
void resizeEvent(QResizeEvent * event)
{
if(model() and model()->columnCount())
for(int column = 0; column < model()->columnCount(); column++)
setColumnWidth(column, event->size().width() / model()->columnCount());
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks